This repository provides a simple Python3 template for creating, running and visualizing backtesting algorithms on a traded security.
- Download and run the IB Client Portal :
./bin/run.sh root/conf.yaml
- Authenticate through the local portal:
https://localhost:5000
- Once authenticated you can make HTTP requests to obtain historical data:
https://localhost:5000/v1/api/iserver/marketdata/history?conid=76792991&period=14d&bar=1h&outsideRth=true
(theconid
is for TSLA)
In the code example I obtain data for Tesla Inc. and generate buy/sell signals based on a simple heuristic.
- Ensure the Client Portal up and authenticated.
- Install the required Python libs
pip install -r requirements.txt
- Run
python3 backtest.py
(this script acts as a template). - A new browser tab will open with the candlestick chart and buy/sell signals.
- The script will output the ROI of the buy/sell signals (excluding transaction fees)
ROI: 5.140722
(in %).
- Name: Ilya Nevolin
- Email: [email protected]