A trading bot created for Trading 212 platform using Selenium framework.
It was created for Upwork project.
Currently app is in demo version, with minimal features implemented.
Note: skip this section if you are going to use Docker.
- Download Go and install it.
- Download Selenium standalone server, and browser web drivers(chromedriver and geckodriver) you will need Java8.0+ version to be able to run it, alternatively you can use already downloaded one in selenium folder.
- Cd to repo folder and run:
chmod +x build.sh; ./build.sh
, it will create a program executable in bin/ folder. - You need Trading212 username/email and password to be able to run the program.
- There is a config/conf.ini file, you can put your credentials there or you can pass your credentials as program arguments. If you cd to bin folder and run:
./web --help
, you can view additional arguments for program or you can input them in conf.ini file. - Before starting program, you have to start Selenium server, cd to selenium folder and run:
java -jar selenium-server.jar
or if you already have running instance you can skip this step. - If you filled config/conf.ini with your creds, you can run program:
./web --inifile
and it will start listening on specified port(default 4000).
- Pull Selenium images from Docker hub, by running following command:
docker pull selenium/hub:latest selenium/base:latest selenium/standalone-chrome:late selenium/standalone-firefox:latest
- Run Selenium standalone server as a container in separate terminal window (you can choose firefox or chrome):
docker run -d -p 4444:4444 -v /dev/shm:/dev/shm selenium/standalone-firefox:latest
- Build Trading212 Trading Bot image:
docker build -t trading212 .
- Run Bot program as a container(you have to input same browser in conf.ini as Selenium standalone server container), it will start listening on specified port(default 4000):
docker run --network "host" trading212
For the purposes of demo program, there is just 1 route coded for now. Using this route, you can buy commodity of your choice at market price, limit/stop is not available for now(read Known Issues). I recommend you to test program using Postman. Just create a new POST request there, input http://127.0.0.1:4000/commodity as a url and finally choose Body -> raw and input following json:
JSON request syntax:
{
"name": "Ethereum" (string), // should be full name of commodity
"quantity": 3.4 (float), // amount you want to buy
"order": "Buy" (string) // type of order, buy or sell(for now just buy is implemented)
"price": 200.10 (float) // not implemented yet
}
JSON response syntax:
{
"success": true/false (boolean), // indication of request success
"error": "" (string), // usually empty or server error message
"data": "" (interface) // output of Alert box after order is done
}
Buying commodity using limit/stop order is not implemented yet, because of famous Selenium issue: element couldn't be scrolled into view. This issue is going to be fixed, as soon as project gets approval.