Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/inevolin/interactivebrokers-backtesting
This repository provides a simple Python3 template for creating and running backtesting algorithms on a historical dataset of a specific security.
https://github.com/inevolin/interactivebrokers-backtesting
backtesting interactive-brokers interactivebrokers python3 trading trading-algorithms
Last synced: 3 days ago
JSON representation
This repository provides a simple Python3 template for creating and running backtesting algorithms on a historical dataset of a specific security.
- Host: GitHub
- URL: https://github.com/inevolin/interactivebrokers-backtesting
- Owner: inevolin
- License: mit
- Created: 2023-10-08T10:09:41.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-08T10:36:42.000Z (about 1 year ago)
- Last Synced: 2023-10-08T11:23:38.735Z (about 1 year ago)
- Topics: backtesting, interactive-brokers, interactivebrokers, python3, trading, trading-algorithms
- Language: Python
- Homepage:
- Size: 22.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# InteractiveBrokers Backtesting
This repository provides a simple Python3 template for creating, running and visualizing backtesting algorithms on a traded security.
![tsla](https://github.com/inevolin/InteractiveBrokers-backtesting/assets/53948000/ab29e8d1-ed60-4fcf-b336-7ed28e402880)
## Getting started
1. Download and run the [IB Client Portal](https://www.interactivebrokers.com/en/trading/ib-api.php) : `./bin/run.sh root/conf.yaml`
2. Authenticate through the local portal: `https://localhost:5000`
3. 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` (the `conid` is for TSLA)## Code
In the code example I obtain data for Tesla Inc. and generate buy/sell signals based on a simple heuristic.1. Ensure the Client Portal up and authenticated.
2. Install the required Python libs `pip install -r requirements.txt`
3. Run `python3 backtest.py` (this script acts as a template).
4. A new browser tab will open with the candlestick chart and buy/sell signals.
5. The script will output the ROI of the buy/sell signals (excluding transaction fees) `ROI: 5.140722` (in %).### Contact
- Name: [Ilya Nevolin](https://www.linkedin.com/in/iljanevolin/)
- Email: [email protected]