Skip to content

Commit

Permalink
Merge pull request #8 from federico123579/dev
Browse files Browse the repository at this point in the history
New Beta4
  • Loading branch information
federico123579 authored Sep 5, 2017
2 parents b0cca33 + ebef471 commit 74d9e7d
Show file tree
Hide file tree
Showing 17 changed files with 561 additions and 76 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ parts/
sdist/
var/
wheels/
test.py
*.egg-info/
.installed.cfg
*.egg
Expand Down
28 changes: 28 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
language: python
python:
- "3.5"
- "3.6"
before_install:
- sudo apt-get update
- sudo apt-get install xvfb
install:
- pip install -U pip
- pip install -r dev-requirements.txt
- pip install .
before_script:
# - wget https://ftp.mozilla.org/pub/firefox/releases/55.0/linux-x86_64/en-US/firefox-55.0.tar.bz2
# - tar -xjf firefox-55.0.tar.bz2
# - sudo mv firefox /opt/firefox55
# - sudo ln -s /opt/firefox55/firefox-bin /usr/bin/firefox
# - wget https://github.com/mozilla/geckodriver/releases/download/v0.18.0/geckodriver-v0.18.0-linux64.tar.gz
# - tar -xvzf geckodriver-v0.18.0-linux64.tar.gz
# - rm geckodriver-v0.18.0-linux64.tar.gz
# - chmod +x geckodriver
# - sudo cp geckodriver /bin/geckodriver
script:
- py.test tests/test.py --doctest-modules --pep8 tradingAPI -v --cov tradingAPI --cov-report term-missing
after_success:
- coveralls
group: stable
dist: precise
os: linux
60 changes: 59 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,45 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

## [Unreleased]

## [0.1b4] - 2017-09-05
### Added
- [a6a9c6d]: Added Dockerfile & dev reqs
- [dad0bd8]: Added Market
- [2f1ba0d]: Added Travis CI & Coveralls
- [7ef1461]: Added virtualdisplay
- [3dab378]: Added BrowserException
- [4d9e3d6]: Added logger

### Changed
- [78a5a9a]: Included logger in setup

### Removed
- [95ca894]: Removed datetime from records

### Fixed
A lot of minor fixies, these are the mayor ones:

- [412f29f]: Fixed prefs bug
- [ce71903]: Fixed **addPrefs** and **clearPrefs** bugs.

## [0.1b3] - 2017-08-28
### Added
- [abdde90]: Added virtual browser (and fixed).
- [07f19ad]: Added sentiment to **addPrefs**.

### Changed
- [b17e6df]: Launch browser function on its own _"self.launch()"_.

## [0.1b2] - 2017-08-27
### Added
- [cbf449a]: Added sentiment to **checkStocks**.

### Fixed
- [64f78e4]: Adjusted price in **checkStocks** _(now without swap)_.

### Deprecated
- [64f78e4]: Date in movements.

## [0.1b1] - 2017-08-24
### Fixed
- Fixed finally **checkStocks**.
Expand All @@ -25,6 +64,25 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
## 0.1a0 - 2017-08-19
Initial version.

[Unreleased]: https://github.com/federico123579/Trading212-API/compare/v0.1a0...HEAD
[Unreleased]: https://github.com/federico123579/Trading212-API/compare/v0.1b3...HEAD
[0.1b3]: https://github.com/federico123579/Trading212-API/compare/v0.1b2...v0.1b3
[0.1b2]: https://github.com/federico123579/Trading212-API/compare/v0.1b1...v0.1b2
[0.1b1]: https://github.com/federico123579/Trading212-API/compare/v0.1a2...v0.1b1
[0.1a2]: https://github.com/federico123579/Trading212-API/compare/v0.1a1...v0.1a2
[0.1a1]: https://github.com/federico123579/Trading212-API/compare/v0.1a0...v0.1a1

[2f1ba0d]: https://github.com/federico123579/Trading212-API/commit/2f1ba0d
[78a5a9a]: https://github.com/federico123579/Trading212-API/commit/78a5a9a
[7ef1461]: https://github.com/federico123579/Trading212-API/commit/7ef1461
[412f29f]: https://github.com/federico123579/Trading212-API/commit/412f29f
[a6a9c6d]: https://github.com/federico123579/Trading212-API/commit/a6a9c6d
[dad0bd8]: https://github.com/federico123579/Trading212-API/commit/dad0bd8
[95ca894]: https://github.com/federico123579/Trading212-API/commit/95ca894
[3dab378]: https://github.com/federico123579/Trading212-API/commit/e25a600
[4d9e3d6]: https://github.com/federico123579/Trading212-API/commit/4d9e3d6
[abdde90]: https://github.com/federico123579/Trading212-API/commit/abdde90
[ce71903]: https://github.com/federico123579/Trading212-API/commit/ce71903
[07f19ad]: https://github.com/federico123579/Trading212-API/commit/07f19ad
[b17e6df]: https://github.com/federico123579/Trading212-API/commit/b17e6df
[cbf449a]: https://github.com/federico123579/Trading212-API/commit/cbf449a
[64f78e4]: https://github.com/federico123579/Trading212-API/commit/64f78e4
35 changes: 35 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM ubuntu:17.10
MAINTAINER Federico Lolli
RUN apt-get -qq update
RUN apt-get -y install wget
################## BEGIN INSTALLATION ######################
RUN apt-get -y install xvfb
RUN apt-get -y install firefox
RUN apt-get -y install python3.6
RUN apt-get -y install python3-venv
RUN apt-get -y install git
##################### INSTALLATION END #####################
##### PIP #####
RUN wget https://bootstrap.pypa.io/get-pip.py
RUN python3.6 get-pip.py
RUN pip install virtualenv
###############
# GECKODRIVER #
RUN wget https://github.com/mozilla/geckodriver/releases/download/v0.16.0/geckodriver-v0.11.1-linux64.tar.gz
RUN tar -xvzf geckodriver-v0.11.1-linux64.tar.gz
RUN rm geckodriver-v0.11.1-linux64.tar.gz
RUN chmod +x geckodriver
RUN cp geckodriver /bin/
RUN rm geckodriver*
###############
# TRADING-BOT #
WORKDIR /home
RUN git clone https://github.com/federico123579/Trading212-API.git trading-api
WORKDIR /home/trading-api
RUN git checkout factory
RUN python3.6 -m venv env
RUN . env/bin/activate
RUN pip install wheel
RUN pip install -r dev-requirements.txt
RUN pip install .
###############
26 changes: 20 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
![Logo of the project](./docs/logo.png)
<p align="center">
<img src="./docs/logo.png">
</p>

# Trading212-API
> API for Trading212 broker service
[![Github All Releases](https://img.shields.io/github/downloads/federico123579/Trading212-API/total.svg)](https://github.com/federico123579/Trading212-API/releases) [![PyPI](https://img.shields.io/pypi/v/trading212api.svg)](https://pypi.python.org/pypi/trading212api)
[![Build Status](https://travis-ci.org/federico123579/trading-bot.svg?branch=master)](https://travis-ci.org/federico123579/trading-bot) [![Coverage Status](https://coveralls.io/repos/github/federico123579/Trading212-API/badge.svg?branch=master)](https://coveralls.io/github/federico123579/Trading212-API?branch=master) [![Code Climate](https://img.shields.io/codeclimate/github/federico123579/Trading212-API.svg)](https://codeclimate.com/github/federico123579/Trading212-API) [![Github All Releases](https://img.shields.io/github/downloads/federico123579/Trading212-API/total.svg)](https://github.com/federico123579/Trading212-API/releases) [![PyPI](https://img.shields.io/pypi/v/trading212api.svg)](https://pypi.python.org/pypi/trading212api)

A python user-interface for Trading 212 using browser automation.

Expand Down Expand Up @@ -44,13 +45,26 @@ the project further:
git clone https://github.com/federico123579/Trading212-API.git
cd Trading212-API/
python3.6 -m venv env
. env/bin//activate
pip install splinter bs4
. env/bin/activate
pip install -r dev-requirements.txt
pip install .
```

#### Docker

Or use a Dockerfile:

```shell
docker build -t tradingapi .
docker run --name tradingapi_instance -it tradingapi
```

### To-do

[ ] add real account login
[ ] fix test.py
[ ] fix addPrefs and clearPrefs
[ ] add closure time

## Versioning

Expand All @@ -77,4 +91,4 @@ REQUIRED - **SOON**

## Licensing

This software is under the MIT license.
This software is under the MIT license.
4 changes: 4 additions & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
python-coveralls
pytest
pytest-cov
pytest-pep8
Binary file modified docs/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

setup(
name="trading212api",
version="0.1b1",
version="0.1b4",
packages=['tradingAPI'],
install_requires=[
'splinter',
'pyvirtualdisplay',
'bs4'
],
include_package_data=True,
package_data={'': ['*.conf']},
zip_safe=False,
author="Federico Lolli",
author_email="[email protected]",
Expand All @@ -26,4 +29,4 @@
'Topic :: Software Development :: User Interfaces',
'Topic :: System :: Emulators'
]
)
)
35 changes: 35 additions & 0 deletions tests/check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from tradingAPI import *


api = API("CRITICAL")


def test_launch():
assert api.launch()


def test_login():
assert api.login("[email protected]", "TestTest1.")


def test_movs():
api.addMov("ethereum", 1, "buy")
api.checkPos()
stock = [x.id for x in api.movements if x.name ==
"ethereum" and x.quantity == 1][0]
api.closeMov(stock)
api.checkPos()
assert len([x.id for x in api.movements if x.name ==
"ethereum" and x.quantity == 1][0]) == 0


def test_clearPrefs():
assert api.clearPrefs()


def test_addPrefs():
assert api.addPrefs(["bitcoin", "ethereum"])


def test_logout():
assert api.logout()
12 changes: 12 additions & 0 deletions tests/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import unittest


class TestAlwaysTrue(unittest.TestCase):

def test_assertTrue(self):
"""
always_true returns a truthy value
"""
result = True

self.assertTrue(result)
4 changes: 3 additions & 1 deletion tradingAPI/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from .api import API
from .api import API

__VERSION__ = "v0.1b4"
Loading

0 comments on commit 74d9e7d

Please sign in to comment.