https://github.com/bentimor/trading212api
An unofficial API for Trading212
https://github.com/bentimor/trading212api
python python3 selenium stocks trading trading-algorithms trading-bot trading212 unofficial
Last synced: about 17 hours ago
JSON representation
An unofficial API for Trading212
- Host: GitHub
- URL: https://github.com/bentimor/trading212api
- Owner: BenTimor
- License: mit
- Created: 2020-08-11T16:10:59.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-04-24T12:11:01.000Z (about 5 years ago)
- Last Synced: 2026-02-25T23:20:22.828Z (5 months ago)
- Topics: python, python3, selenium, stocks, trading, trading-algorithms, trading-bot, trading212, unofficial
- Language: Python
- Homepage:
- Size: 25.4 KB
- Stars: 54
- Watchers: 9
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Trading212 API
### Right now the API is not always working properly. I don't have enough time to fix it, But everyone is more than welcome to contribute and I'll check all of the PRs.
This is an **unofficial** selenium based API for 'Trading212' broker.
**Neither me and neither Trading212 are responsible for the API, You are responsible for your actions and for using the API.**
Additionally, Note the Trading212 ['Robo Trading' agreement](https://www.trading212.com/en/robo-trading-agreement).
The API is still WIP, I don't know if and how it's going to work on your computer. But you're more than welcome to open and issue and I'll try to help as much as I can.
## Requirements
- Python 3.x
- Selenium package
- GeckoDriver
- FireFox browser
## Installation
`pip install trading212`
## Import
CFD mode:
````
from Trading212 import CFD
trading = CFD(email, password) # For practice
trading = CFD(email, password, panel=Panel.Real) # For real money
````
Invest mode:
````
from Trading212 import Invest
trading = Invest(email, password) # For practice
trading = Invest(email, password, panel=Panel.Real) # For real money
````
## Usage
First of all, You have to know that the API currently uses the **display name** of the stocks.
#### Buying a stock ('Long')
`trading.buy_stock(stock, amount)`
#### Selling a stock ('Short')
`trading.sell_stock(stock, amount) # Available for CFD only`
#### Closing a position
`trading.close_position(stock)`
#### Getting a result of a position
`trading.result(stock)`
#### Getting another information of a position
`trading.position_info(css_class)`
You can get anything that's written in the bar. I've added a picture with source code so you'll be able to select the class.
