Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ismet55555/interactive_broker_playground
Just testing things out with interactive broker API
https://github.com/ismet55555/interactive_broker_playground
Last synced: 12 days ago
JSON representation
Just testing things out with interactive broker API
- Host: GitHub
- URL: https://github.com/ismet55555/interactive_broker_playground
- Owner: ismet55555
- Created: 2021-09-18T21:16:42.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-01-23T21:46:41.000Z (almost 2 years ago)
- Last Synced: 2024-11-05T07:40:31.485Z (about 2 months ago)
- Language: Python
- Size: 94.7 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# interactive_broker_playground
In this repository we are simply playing around with the Interactive Brokers API
# Repo Setup
This repository is divided into two sections.
1. Native API Scripts (`native_api`)
- This library is developed and maintained by Interactive Brokers
- It is downloaded via the Interactive Brokers website and installed manually
- Documentation: https://interactivebrokers.github.io/tws-api/index.html2. `ib_insync`
- This library is a wrapper on the native interactive broker API
- It makes working with the native library easier and asynchronous
- GitHub Repo: https://github.com/erdewit/ib_insync# Installation and Setup
### Interactive Broker Trader Workstation (TWS)
In order to use any code that interacts with the interactive broker servers, a local client has to be installed.
This local client can either be the TWS or the Interactive Broker Gateway.- TWS: Download, install, run, and log-in
- https://www.interactivebrokers.com/en/index.php?f=16042
- TWS: Change Settings
- File > Global Configuration > API > Settings
- Check: `Enable ActiveX and Socket Clients`
- Uncheck: `Read-Only API`
- Ensure: `Socket port: 7497`
- Check: `Allow connections form localhost only` _(Uncheck if connecting from remote computer)_# Market/Data Analysis Tools
Interactive brokers API is great for getting data and managing orders, however for any data or market analysis another tools needed. The following tools enable any technical analysis.
### Stockstats
A open-source technical analysis tool for python.
- GitHub Repo: https://github.com/jealous/stockstats
- `pip install stockstats`### TA-Lib Market Analysis Tool
TA-Lib is an open-source technical analysis toolkit. See [home page](https://ta-lib.org/).
While the original library is not available in Python, a wrapper is available to allow Python users access.- GitHub Repo: https://github.com/mrjbq7/ta-lib
- Follow instructions how to download compressed file and build from source
- `pip install ta-lib`### Bta-Lib Market Analysis Tool
- GitHub Repo: https://github.com/mementum/bta-lib
- Website: https://btalib.backtrader.com/
- `pip install bta-lib`# NOTES
- Connection
- `Python API <-> TWS/Gateway Client <-> Interactive Broker Servers`
- Python Script Communication
- Outgoing: `Python Script -> EClient -> TWS/Gateway Client`
- Incoming: `Python Script <- EWrapper <- TWS/Gateway Client`- Sector Types
- 'STK' = Stock (or ETF)
- 'OPT' = Option
- 'FUT' = Future
- 'IND' = Index
- 'FOP' = Futures option
- 'CASH' = Forex pair
- 'CFD' = CFD
- 'BAG' = Combo
- 'WAR' = Warrant
- 'BOND'= Bond
- 'CMDTY'= Commodity
- 'NEWS' = News
- 'FUND'= Mutual fund- P1L0veTorontoUrenan823
# Links
- Native Python API
- [Tutorial](https://algotrading101.com/learn/interactive-brokers-python-api-native-guide/)
- [Available Tick Types](https://interactivebrokers.github.io/tws-api/tick_types.html)
- [Market Data Types](https://interactivebrokers.github.io/tws-api/market_data_type.html)- Historical Data
- [Requesting Historical Bar Data](https://interactivebrokers.github.io/tws-api/historical_bars.html)
- [Historical Data Limitations](https://interactivebrokers.github.io/tws-api/historical_limitations.html)
- Examples:
- [Get Historical Data - Github Gist](https://gist.github.com/robcarver17/f50aeebc2ecd084f818706d9f05c1eb4#file-temp-py)
- [CLI to Download Historical Data - GitHub Gist](https://gist.github.com/wrighter/dd201adb09518b3c1d862255238d2534)
- [Receiving Market Data and Historical Candlesticks](https://tradersacademy.online/trading-topics/trader-workstation-tws/receiving-market-data-and-historical-candlesticks)- Orders
- [Available Orders](https://interactivebrokers.github.io/tws-api/available_orders.html)
- [Order Managment](https://interactivebrokers.github.io/tws-api/order_management.html)- Message Codes
- [Message Codes](https://interactivebrokers.github.io/tws-api/message_codes.html)- `ib_insync` Python Library
- Details:
- Utilizes asynchronous methods to communicate with the native API to increase efficiency.
- Utilizes the asyncio library to provide an asynchronous single thread to interact with the API
- Simplifies the process of receiving data from the API.
- [Tutorial](https://algotrading101.com/learn/ib_insync-interactive-brokers-api-guide/)
- [Code Recipes](https://github.com/erdewit/ib_insync/blob/master/docs/recipes.rst)
- [Tkinter UI Example](https://github.com/erdewit/ib_insync/blob/master/examples/tk.py)
- [Market Scanner Examples](https://groups.io/g/insync/topic/market_data_scanners/22402297?p=,,,20,0,0,0::recentpostdate/sticky,,,20,2,0,22402297,previd=9223372036854775807,nextid=1630545430030066183&previd=9223372036854775807&nextid=1630545430030066183)
- [Examples](https://market-and-us.com/blog/how-to-code-all-about-orders-with-interactive-brokers-475/)
- [Presentation for Jupyter Notebook](https://www.palmislandtraders.com/econ136/ib_api.pdf)- `IbPy` Python Library
- Another library and a wrapper of the Interactive Broker API
- [GitHub Repo](https://github.com/blampe/IbPy)