A command line interface and Python framework for the Interactive Brokers APIs.
IB Quant leverages ib-insync to interface with Interactive Brokers TWS or Gateway.
The CLI is named ib.
After installing ibquant, ib's command groups can be shown in terminal with:
ib --helpcore.AppBase serves as a base for all other core classes
core.Trader drives a user defined strategy in live trading
core.Brute enables brute force optimization of rules based trading strategies
core.Learner is used to optimize gradient based learning strategies
mixins.AccountMixins enables account features for non-advisor accounts
mixins.AdvisorMixins enables features for an advisor account (groups, model portfolios)
mixins.ConnectionMixins handles the connection to the running TWS or Gateway sesion
mixins.ContractMixins provides an extended class to define contracts for the TWS API
mixins.DataMixins provides utilities for fetching historical data, and for streaming top of book or limit order book data.
mixins.OrderMixins provides interfaces for several TWS order types
mixins.StrategyMixins provides a base class for user defined strategies
The package can be installed for standard use or for development.
Required dependencies for standard use as a package are shown in setup.cfg under install_requires of the options group.
Dev dependencies are shown in setup.cfg under the options.extras_require group.
After cloning the repo, the framework can be installed for use as intended with:
# assuming conda
conda env create -n ibquant -y
conda activate ibquant
pip install {{ path to ibquant clone }}After cloning the repo, the framework can be installed for development with:
# creating a virtual environment
cd {{ path to ibquant clone }}
python3 -m venv .venv/
# Activate the environment
# Linux and MacOS
source .venv/bin/activate
# Windows
.venv\Scripts\activate.bat
# install an editable version of the package
pip install -e .After installing ibquant, log into a TWS paper account and test example flows from terminal with:
ib advisor managed-accountsib account summaryib contract lookup --contract-type=FutureEach of the above commands will prompt the user for required inputs.
localSymbol, multiplier, and currency prompts of
ib contract lookupare not required
Aside from using ib-insync, ibtrader also provides users with:
- QuantLib
- alphalens-reloaded: community maintained version of Quantopian alphalens
- empyrical-reloaded: community maintained version of Quantopian empyrical
- pyfolio-reloaded: community maintained version of Quantopian pyfolio
- zipline-reloaded: community maintained version of Quantopian zipline
- nasdaq-data-link: formerly known as Quandl
- PyEX: an IEX Cloud API tool
- TA-Lib: a technical analysis library common to PyEX and Zipline
Zipline Reloaded provides factors and indicators in the pipeline API. TA-Lib is installed as a dependency of Zipline. Most factors and indicators of both libraries will be reachable via ibtrader.factors.
Indicator definitions can be found at:
- Trading Technologies Glossary
- thinkorswim Studies Library
- IBKR Technical Analytics Guide
Sample strategies can be found via the link below.
- thinkorswim Strategies Library
The texts shown below are merely suggestions; each text is written by Dr. Yves Hilpisch. The content is not heavy on math notation, and the author has done a great job at providing code examples.
- Python for Algorithmic Trading
- Financial Theory with Python
- Artificial Intelligence in Finance
- Derivatives Analytics with Python
As with the above, the books shown below are considered standard suggestions.
- Fluent Python (Ramalho)
- High Performance Python (Gorelick et al)
- Python for Data Analysis (McKinney)
Aside from the texts, and possibly a more suitable way to learn professional level Python programming, is to look at the source code of the Quantopian reloaded projects.
The resources shown below are free, and sourced from reputable providers.
- TD Ameritrade Network YouTube
- Interactive Brokers Traders' Academy
- Interactive Brokers Quant Blog
- Interactive Brokers YouTube
- CME Group Markets
- CME Group Education
- CME Group YouTube
- CBOE Markets
- CBOE Options Institute
- CBOE YouTube
- NASDAQ Market Activity
- NASDAQ News and Insights
- Quantopian YouTube
- tastytrade (the original thinkorswim team)
- Alpha Architect Blog
- Quantocracy Blogs
- arXiv Quantitative Finance papers
- Man Group Insights
- FINRA Investors Education
- Corporate Finance Institute free courses