QuantRocket logo

Interactive Brokers Steps

To prepare for live trading with Interactive Brokers, the following steps are required:

Collect listings from IBKR

To place orders and/or collect real-time data through Interactive Brokers, it is necessary to collect securities master listings from Interactive Brokers. It is not sufficient to have collected the listings from another vendor; specific IBKR fields must be present in the securities master database in order to allow QuantRocket to communite with the IBKR API.

First, start IB Gateway:

Then collect the listings for all US stocks:

Monitor flightlog for completion, which may take several hours. (You can continue with the setup process while waiting for the listings collection to finish.)

Real-time database

Next, create the real-time database. These steps simply create the database. Real-time data collection will be initiated from the Zipline strategy code. First, create the tick database:

Then create the 1-minute aggregate database derived from the tick database:

Specify an exchange

Unlike some brokers, Interactive Brokers requires that you specify an exchange when submitting orders. In the sell-gap.py file, find the block of code where orders are placed and add the exchange param, for example exchange="SMART":

algo.order_value(
    asset,
    context.target_value_per_position,
    style=MarketOrder(exchange="SMART")
)

Repeat this step for the block of code that places orders to close positions.


Next Up

Part 8: Account Allocation and Scheduling