Brokerages
Interactive Brokers
Introduction
QuantConnect enables you to run your algorithms in live mode with real-time market data. We have successfully hosted more than 200,000 live algorithms and have had more than $22B in volume traded on our servers since 2015. Brokerages supply a connection to the exchanges so that you can automate orders using LEAN. You can use multiple data feeds in live trading algorithms.
Interactive Brokers (IB) was founded by Thomas Peterffy in 1993 with the goal to "create technology to provide liquidity on better terms. Compete on price, speed, size, diversity of global products and advanced trading tools". IB provides access to trading Equities, ETFs, Options, Futures, Future Options, Forex, Gold, Warrants, Bonds, and Mutual Funds for clients in over 200 countries and territories with no minimum deposit. IB also provides paper trading, a trading platform, and educational services.
To view the implementation of the IB brokerage integration, see the Lean.Brokerages.InteractiveBrokers repository.
Account Types
The IB API does not support the IBKR LITE plan. You need an IBKR PRO plan. Individual and Financial Advisor (FA) accounts are available.
Individual Accounts
IB supports cash and margin accounts.
SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage, AccountType.Cash); SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage, AccountType.Margin);
self.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage, AccountType.Cash) self.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage, AccountType.Margin)
FA Accounts
IB supports FA accounts for Trading Firm and Institution organizations. FA accounts enable certified professionals to use a single trading algorithm to manage several client accounts. For more information about FA accounts, see Financial Advisors.
Create an Account
You need to open an IBKR Pro account to deploy algorithms with IB. The IB API does not support IBKR Lite accounts. To create an IB account, see the Open an Account page on the IB website.
You need to activate IBKR Mobile Authentication (IB Key) to deploy live algorithms with your brokerage account. After you open your account, follow the installation and activation instructions on the IB website.
Paper Trading
IB supports paper trading. Follow the Opening a Paper Trading Account page in the IB documentation to set up your paper trading account.
If you want to use IB data feeds and trade with your paper trading account, follow these steps:
- Log in to the IB Client Portal.
- In the top-right corner, click the person icon and then click .
- In the Account Configuration section, click Paper Trading Account.
- Click .
- Click .
The IB paper trading environment simulates most aspects of a production Trader Workstation account, but you may encounter some differences due to its construction as a simulator with no execution or clearing abilities.
Financial Advisors
IB supports FA accounts for Trading Firm and Institution organizations. FA accounts enable certified professionals to use a single trading algorithm to manage several client accounts.
To place trades using a subset of client accounts, create Account Groups in Trader Workstation and then define the InteractiveBrokersOrderProperties
when you create orders.
DefaultOrderProperties = new InteractiveBrokersOrderProperties { FaGroup = "TestGroupEQ", FaMethod = "EqualQuantity", FaProfile = "TestProfileP", Account = "DU123456" };
self.DefaultOrderProperties = InteractiveBrokersOrderProperties() self.DefaultOrderProperties.FaGroup = "TestGroupEQ" self.DefaultOrderProperties.FaMethod = "EqualQuantity" self.DefaultOrderProperties.FaProfile = "TestProfileP" self.DefaultOrderProperties.Account = "DU123456"
SecurityHolding objects aggregate your positions across all the account groups. If you have two groups where group A has 10 shares of SPY and group B has -10 shares of SPY, then self.Portfolio["SPY"].Quantity
Portfolio["SPY"].Quantity
is zero.
The following table shows the supported allocation methods for FA group orders:
FaMethod | Description |
---|---|
"EqualQuantity" | Distributes shares equally between all accounts in the group. If you use this method, specify an order quantity. |
"NetLiq" | Distributes shares based on the net liquidation value of each account. The system calculates ratios based on the net liquidation value in each account and allocates shares based on these ratios. If you use this method, specify an order quantity. |
"AvailableEquity" | Distributes shares based on the amount of available equity in each account. The system calculates ratios based on the available equity in each account and allocates shares based on these ratios. If you use this method, specify an order quantity. |
"PctChange" | Increases or decreases an already existing position. Positive percents increase positions and negative percents decrease positions. If you use this method, specify a percent instead of an order quantity. |
public override void Initialize() { // Set the default order properties DefaultOrderProperties = new InteractiveBrokersOrderProperties() { FaGroup = "TestGroupEQ", FaMethod = "EqualQuantity", FaProfile = "TestProfileP", Account = "DU123456" }; } public override void OnData(Slice slice) { // Use default order order properties LimitOrder(_symbol, quantity, limitPrice); // Override the default order properties // "NetLiq" requires a order size input LimitOrder(_symbol, quantity, limitPrice, orderProperties: new InteractiveBrokersOrderProperties { FaMethod = "NetLiq" }); // "AvailableEquity" requires a order size input LimitOrder(_symbol, quantity, limitPrice, orderProperties: new InteractiveBrokersOrderProperties { FaMethod = "AvailableEquity" }); // "PctChange" requires a percentage of portfolio input SetHoldings(_symbol, pctPortfolio, orderProperties: new InteractiveBrokersOrderProperties { FaMethod = "PctChange" }); }
def Initialize(self) -> None: # Set the default order properties self.DefaultOrderProperties = InteractiveBrokersOrderProperties() self.DefaultOrderProperties.FaGroup = "TestGroupEQ" self.DefaultOrderProperties.FaMethod = "EqualQuantity" self.DefaultOrderProperties.FaProfile = "TestProfileP" self.DefaultOrderProperties.Account = "DU123456" def OnData(self, slice: Slice) -> None: # Override the default order properties # "NetLiq" requires a order size input order_properties = InteractiveBrokersOrderProperties() order_properties.FaMethod = "NetLiq" self.LimitOrder(self.symbol, quantity, limit_price, orderProperties=order_properties) # "AvailableEquity" requires a order size input order_properties.FaMethod = "AvailableEquity" self.LimitOrder(self.symbol, quantity, limit_price, orderProperties=order_properties) # "PctChange" requires a percentage of portfolio input order_properties.FaMethod = "PctChange" self.SetHoldings(self.symbol, pct_portfolio, orderProperties=order_properties)
Asset Classes
Our IB integration supports trading Equities, Options, Forex, Futures, Future Options, and Index Options.
AddEquity("SPY", Resolution.Minute, Market.USA); AddOption("SPY", Resolution.Minute, Market.USA); AddForex("EURUSD", Resolution.Minute, Market.Oanda).Symbol; var goldFutures = AddFuture(Futures.Metals.Gold, Resolution.Minute, Market.CME); AddFutureOption(goldFutures.Symbol, universe => universe.Strikes(-5, +5)); var vixIndex = AddIndex("VIX", Resolution.Minute, Market.USA); AddIndexOption(vixIndex.Symbol);
self.AddEquity("SPY", Resolution.Minute, Market.USA) self.AddOption("SPY", Resolution.Minute, Market.USA) self.AddForex("EURUSD", Resolution.Minute, Market.Oanda).Symbol gold_futures = self.AddFuture(Futures.Metals.Gold, Resolution.Minute, Market.CME) self.AddFutureOption(gold_futures.Symbol, lambda universe: universe.Strikes(-5, +5)) vix_index = self.AddIndex("VIX", Resolution.Minute, Market.USA) self.AddIndexOption(vix_index.Symbol)
If you call the SetBrokerageModel
method with the correct BrokerageName
, then you don't need to pass a Market
argument to the method calls above because the brokerage model has default markets.
Assets Available
Refer to the dataset listing of the asset class you are trading to see the assets available. The following table shows the dataset listing of each asset class supported by IB:
Asset Class | Dataset Listing |
---|---|
Equities | US Equities |
Options | US Equity Options |
Forex | FOREX Data |
Futures | US Futures |
Future Options | US Future Options |
Index Options | US Index Options |
Data Feeds
You might need to purchase an IB data subscription for your trading. For more information about live data feeds, see Data Feeds.
ETFs
You may not be able to trade all assets with Interactive Brokers. For example, if you live in the EU, you can't trade US ETFs. Check with your local regulators to know which assets you are allowed to trade. You may need to adjust settings in your brokerage account to live trade some assets.
Orders
We model the IB API by supporting several order types, order properties, and order updates. When you deploy live algorithms, you can place manual orders through the IDE.
Order Types
The following table describes the order types that IB supports. For specific details about each order type, refer to the IB documentation.
Order Type | IB Documentation Page |
---|---|
MarketOrder | Market Orders |
LimitOrder | Limit Orders |
LimitIfTouchedOrder | Limit if Touched Orders |
StopMarketOrder | Stop Orders |
StopLimitOrder | Stop-Limit Orders |
MarketOnOpenOrder | Market-on-Open (MOO) Orders |
MarketOnCloseOrder | Market-on-Close (MOC) Orders |
ComboMarketOrder | Spread Orders |
ComboLimitOrder | Spread Orders |
ComboLegLimitOrder | Spread Orders |
ExerciseOption | Options Exercise |
MarketOrder(_symbol, quantity); LimitOrder(_symbol, quantity, limitPrice); LimitIfTouchedOrder(_symbol, quantity, triggerPrice, limitPrice); StopMarketOrder(_symbol, quantity, stopPrice); StopLimitOrder(_symbol, quantity, stopPrice, limitPrice); MarketOnOpenOrder(_symbol, quantity); MarketOnCloseOrder(_symbol, quantity); ExerciseOption(_optionSymbol, quantity);
self.MarketOrder(self.symbol, quantity) self.LimitOrder(self.symbol, quantity, limit_price) self.LimitIfTouchedOrder(self.symbol, quantity, trigger_price, limit_price) self.StopMarketOrder(self.symbol, quantity, stop_price) self.StopLimitOrder(self.symbol, quantity, stop_price, limit_price) self.MarketOnOpenOrder(self.symbol, quantity) self.MarketOnCloseOrder(self.symbol, quantity) self.ExerciseOption(self.option_symbol, quantity)
Market on open orders aren't available for Futures or Future Options.
Option exercise orders aren't available for Index Options or cash-settled US Equity Options.
Combo orders are only available for Options.
Order Properties
We model custom order properties from the IB API. The following table describes the members of the InteractiveBrokersOrderProperties
object that you can set to customize order execution. The table does not include the preceding methods for FA accounts.
Property | Description |
---|---|
TimeInForce | A TimeInForce instruction to apply to the order. The following instructions are supported:
|
OutsideRegularTradingHours | A flag to signal that the order may be triggered and filled outside of regular trading hours. |
public override void Initialize() { // Set the default order properties DefaultOrderProperties = new InteractiveBrokersOrderProperties { TimeInForce = TimeInForce.GoodTilCanceled, OutsideRegularTradingHours = false }; } public override void OnData(Slice slice) { // Use default order order properties LimitOrder(_symbol, quantity, limitPrice); // Override the default order properties LimitOrder(_symbol, quantity, limitPrice, orderProperties: new InteractiveBrokersOrderProperties { TimeInForce = TimeInForce.Day, OutsideRegularTradingHours = false }); LimitOrder(_symbol, quantity, limitPrice, orderProperties: new InteractiveBrokersOrderProperties { TimeInForce = TimeInForce.GoodTilDate(new DateTime(year, month, day)), OutsideRegularTradingHours = true }); }
def Initialize(self) -> None: # Set the default order properties self.DefaultOrderProperties = InteractiveBrokersOrderProperties() self.DefaultOrderProperties.TimeInForce = TimeInForce.GoodTilCanceled self.DefaultOrderProperties.OutsideRegularTradingHours = False def OnData(self, slice: Slice) -> None: # Use default order order properties self.LimitOrder(self.symbol, quantity, limit_price) # Override the default order properties order_properties = InteractiveBrokersOrderProperties() order_properties.TimeInForce = TimeInForce.Day order_properties.OutsideRegularTradingHours = True self.LimitOrder(self.symbol, quantity, limit_price, orderProperties=order_properties) order_properties.TimeInForce = TimeInForce.GoodTilDate(datetime(year, month, day)) self.LimitOrder(self.symbol, quantity, limit_price, orderProperties=order_properties)
Updates
IB supports order updates. You can define the following members of an UpdateOrderFields
object to update active orders:
Quantity
LimitPrice
StopPrice
TriggerPrice
Tag
var ticket = StopLimitOrder(symbol, quantity, stopPrice, limitPrice, tag); var orderFields = new UpdateOrderFields {
Quantity = newQuantity,
LimitPrice = newLimitPrice,
StopPrice = newStopPrice,
Tag = newTag
}; ticket.Update(orderFields);
ticket = self.StopLimitOrder(symbol, quantity, stop_price, limit_price, tag)
update_fields = UpdateOrderFields() update_fields.Quantity = new_quantity
update_fields.LimitPrice = new_limit_price
update_fields.StopPrice = new_stop_price update_fields.Tag = new_tag ticket.Update(update_fields)
Fill Time
IB has a 400 millisecond fill time for live orders.
Financial Advisor Group Orders
To place FA group orders, see Financial Advisors.
Handling Splits
In live trading, if you're using raw data normalization and you have active limit, stop limit, or stop market orders in the market for a US Equity when a stock split occurs, the quantity, limit price, and stop price of your orders are automatically adjusted to reflect the stock split.
Order Size Limits
The following table shows the maximum number of units you can buy of each currency when the currency is the base currency in a Forex pair:
Base Currency | Description | Maximum Order Size (Millions) |
---|---|---|
USD | US Dollar | 7 |
AUD | Australian Dollar | 6 |
CAD | Canadian Dollar | 6 |
CHF | Swiss Franc | 6 |
CNH | China Renminbi (offshore) | 40 |
CZK | Czech Koruna | 0 |
DKK | Danish Krone | 35 |
EUR | Euro | 5 |
GBP | British Pound Sterling | 4 |
HKD | Hong Kong Dollar | 50 |
HUF | Hungarian Forint | 0 |
HKD | Israeli Shekel | 0 |
KRW | Korean Won | 750 |
JPY | Japanese Yen | 550 |
MXN | Mexican Peso | 70 |
NOK | Norwegian Krone | 35 |
NZD | New Zealand Dollar | 8 |
RUB | Russian Ruble | 30 |
SEK | Swedish Krona | 40 |
SGD | Singapore Dollar | 8 |
Fees
We model the order fees of IB for each asset class. To check the latest fees, see the Commissions page on the IB website.
US Equities
US Equity trades cost $0.005/share with a $1 minimum fee and a 0.5% maximum fee.
Equity Options and Index Options
Equity Options and Index Options fees are a function of your monthly volume and the premium of the contract you trade. The following table shows the fees for each volume tier:
Monthly Volume (Contacts) | Premium ($) | Fee per Contract ($) |
---|---|---|
<= 10,000 | < 0.05 | 0.25 |
<= 10,000 | 0.05 <= premium < 0.10 | 0.50 |
<= 10,000 | >= 0.10 | 0.70 |
10,000 < volume <= 50,000 | < 0.05 | 0.25 |
10,000 < volume <= 50,000 | >= 0.05 | 0.50 |
50,000 < volume <= 100,000 | Any | 0.25 |
> 100,000 | Any | 0.15 |
By default, LEAN models your fees at the tier with the lowest monthly volume. To adjust the fee tier, manually set the fee model and provide a monthlyOptionsTradeAmountInContracts
argument.
There is no fee to exercise Option contracts.
Forex
Forex fees are a function of your monthly Forex trading volume. The following table shows the fee tiers:
Monthly Volume (USD) | Commission Rate (%) | Minimum Fee ($) |
---|---|---|
<= 1B | 0.002 | 2 |
1B < volume <= 2B | 0.0015 | 1.5 |
2B < volume <= 5B | 0.001 | 1.25 |
> 5B | 0.0008 | 1 |
By default, LEAN models your fees at the tier with the lowest monthly volume. To adjust the fee tier, manually set the fee model and provide a monthlyForexTradeAmountInUSDollars
argument.
US Futures
US Futures fees depend on the contracts you trade. The following table shows the base fee per contract for each Future:
Contract Symbol | Market | Name | Base Fee Per Contract ($) | Exchange Fee Per Contract ($) |
---|---|---|---|---|
E-mini Futures | ||||
ES | CME | E-mini S&P 500 Futures | 0.85 | 1.28 |
NQ | CME | E-mini Nasdaq-100 Futures | 0.85 | 1.28 |
YM | CBOT | E-mini Dow ($5) Futures | 0.85 | 1.28 |
RTY | CME | E-mini Russell 2000 Index Futures | 0.85 | 1.28 |
EMD | CME | E-mini S&P MidCap 400 Futures | 0.85 | 1.28 |
Micro E-mini Futures | ||||
MYM | CBOT | Micro E-mini Dow Jones Industrial Average Index Futures | 0.25 | 0.3 |
M2K | CME | Micro E-mini Russell 2000 Index Futures | 0.25 | 0.3 |
MES | CME | Micro E-mini Standard and Poor's 500 Stock Price Index Futures | 0.25 | 0.3 |
MNQ | CME | Micro E-mini Nasdaq-100 Index Futures | 0.25 | 0.3 |
2YY | CBOT | Micro 2-Year Yield Futures | 0.25 | 0.3 |
5YY | CBOT | Micro 5-Year Yield Futures | 0.25 | 0.3 |
10Y | CBOT | Micro 10-Year Yield Futures | 0.25 | 0.3 |
30Y | CBOT | Micro 30-Year Yield Futures | 0.25 | 0.3 |
MCL | NYMEX | Micro WTI Crude Oil Futures | 0.25 | 0.3 |
MGC | COMEX | Micro Gold Futures | 0.25 | 0.3 |
SIL | COMEX | Micro Silver Futures | 0.25 | 0.3 |
Cryptocurrency Futures | ||||
BTC | CME | Bitcoin Futures | 5 | 6 |
MIB | CME | BTIC on Micro Bitcoin Futures | 2.25 | 2.5 |
MBT | CME | Micro Bitcoin Futures | 2.25 | 2.5 |
MET | CME | Micro Ether Futures | 0.2 | 0.2 |
MRB | CME | BTIC on Micro Ether Futures | 0.2 | 0.2 |
E-mini FX Futures | ||||
E7 | CME | E-mini Euro FX Futures | 0.5 | 0.85 |
J7 | CME | E-mini Japanese Yen Futures | 0.5 | 0.85 |
Micro E-mini FX Futures | ||||
M6E | CME | Micro Euro/U.S. Dollar (EUR/USD) Futures | 0.15 | 0.24 |
M6A | CME | Micro Australian Dollar/U.S. Dollar (AUD/USD) Futures | 0.15 | 0.24 |
M6B | CME | Micro British Pound Sterling/U.S. Dollar (GBP/USD) Futures | 0.15 | 0.24 |
MCD | CME | Micro Canadian Dollar/U.S.Dollar(CAD/USD) Futures | 0.15 | 0.24 |
MJY | CME | Micro Japanese Yen/U.S. Dollar (JPY/USD) Futures | 0.15 | 0.24 |
MSF | CME | Micro Swiss Franc/U.S. Dollar (CHF/USD) Futures | 0.15 | 0.24 |
M6J | CME | Micro USD/JPY Futures | 0.15 | 0.24 |
MIR | CME | Micro INR/USD Futures | 0.15 | 0.24 |
M6C | CME | Micro USD/CAD Futures | 0.15 | 0.24 |
M6S | CME | Micro USD/CHF Futures | 0.15 | 0.24 |
MNH | CME | Micro USD/CNH Futures | 0.15 | 0.24 |
If you trade a contract that's not in the preceding table, the base fee is $0.85/contract and the exchange fee is $1.60/contract.
In addition to the base fee and exchange fee, there is a $0.02/contract regulatory fee.
Futures Options
Futures Options fees depend on the contracts you trade. The following table shows the base fee per contract for each Future:
Contract Symbol | Market | Underlying Futures Name | Base Fee Per Contract ($) | Exchange Fee Per Contract ($) |
---|---|---|---|---|
E-mini Futures Options | ||||
ES | CME | E-mini S&P 500 Futures | 0.85 | 0.55 |
NQ | CME | E-mini Nasdaq-100 Futures | 0.85 | 0.55 |
YM | CBOT | E-mini Dow ($5) Futures | 0.85 | 0.55 |
RTY | CME | E-mini Russell 2000 Index Futures | 0.85 | 0.55 |
EMD | CME | E-mini S&P MidCap 400 Futures | 0.85 | 0.55 |
Micro E-mini Futures Options | ||||
MYM | CBOT | Micro E-mini Dow Jones Industrial Average Index Futures | 0.25 | 0.2 |
M2K | CME | Micro E-mini Russell 2000 Index Futures | 0.25 | 0.2 |
MES | CME | Micro E-mini Standard and Poor's 500 Stock Price Index Futures | 0.25 | 0.2 |
MNQ | CME | Micro E-mini Nasdaq-100 Index Futures | 0.25 | 0.2 |
2YY | CBOT | Micro 2-Year Yield Futures | 0.25 | 0.2 |
5YY | CBOT | Micro 5-Year Yield Futures | 0.25 | 0.2 |
10Y | CBOT | Micro 10-Year Yield Futures | 0.25 | 0.2 |
30Y | CBOT | Micro 30-Year Yield Futures | 0.25 | 0.2 |
MCL | NYMEX | Micro WTI Crude Oil Futures | 0.25 | 0.2 |
MGC | COMEX | Micro Gold Futures | 0.25 | 0.2 |
SIL | COMEX | Micro Silver Futures | 0.25 | 0.2 |
Cryptocurrency Futures Options | ||||
BTC | CME | Bitcoin Futures | 5 | 5 |
MIB | CME | BTIC on Micro Bitcoin Futures | 1.25 | 2.5 |
MBT | CME | Micro Bitcoin Futures | 1.25 | 2.5 |
MET | CME | Micro Ether Futures | 0.1 | 0.2 |
MRB | CME | BTIC on Micro Ether Futures | 0.1 | 0.2 |
If you trade a contract that's not in the preceding table, the base fee is $0.85/contract and the exchange fee is $1.60/contract.
In addition to the base fee and exchange fee, there is a $0.02/contract regulatory fee.
For default backtest fee model, see Interactive Brokers Supported Models.
Margin
We model buying power and margin calls to ensure your algorithm stays within the margin requirements.
Buying Power
In the US, IB allows up to 2x leverage on Equity trades for margin accounts. In other countries, IB may offer different amounts of leverage. To figure out how much leverage you can access, check with your local legislation or contact an IB representative. We model the US version of IB leverage by default.
Margin Calls
Regulation T margin rules apply. When the amount of margin remaining in your portfolio drops below 5% of the total portfolio value, you receive a warning. When the amount of margin remaining in your portfolio drops to zero or goes negative, the portfolio sorts the generated margin call orders by their unrealized profit and executes each order synchronously until your portfolio is within the margin requirements.
Pattern Day Trading
If all of the following statements are true, you are classified as a pattern day trader:
- You reside in the United States.
- You trade in a margin account.
- You execute 4+ intraday US Equity trades within 5 business days.
- Your intraday US Equity trades represent more than 6% of your total trades.
Pattern day traders must maintain a minimum equity of $25,000 in their margin account to continue trading. For more information about pattern day trading, see Am I a Pattern Day Trader? on the FINRA website.
The PatternDayTradingMarginModel
doesn't enforce minimum equity rules and doesn't limit your trades, but it adjusts your available leverage based on the market state. During regular market hours, you can use up to 4x leverage. During extended market hours, you can use up to 2x leverage.
security.MarginModel = new PatternDayTradingMarginModel();
security.MarginModel = PatternDayTradingMarginModel()
In live trading, if you have less than $25,000 in your account and you try to open a 4th day trade for an Equity asset in a 5 business day period, you'll get the following error message:
Slippage
Orders through IB do not experience slippage in backtests. In paper trading and live trading, your orders may experience slippage.
For default backtest slippage model, see Interactive Brokers Supported Models.
Fills
We fill market orders immediately and completely in backtests. In live trading, if the quantity of your market orders exceeds the quantity available at the top of the order book, your orders are filled according to what is available in the order book.
For default fill model, see Interactive Brokers Supported Models.
Settlements
If you trade with a margin account, trades settle immediately
security.SettlementModel = new ImmediateSettlementModel();
security.SettlementModel = ImmediateSettlementModel()
For default settlement model, see Interactive Brokers Supported Models.
Security and Stability
When you deploy live algorithms with IB, we don't save your brokerage account credentials.
We call the IB API to place live trades. Sometimes the API may be down. Check the IB status page to see if the API is currently working.
Connections
By default, IB only supports one connection at a time to your account. If you interfere with your brokerage account while an algorithm is connected to it, the algorithm may stop executing. If you deploy a live running algorithm with your IB account and want to open Trader Workstation (TWS) with the same IB account, create a second user on your IB account and log in to TWS with the new user credentials. To run more than one algorithm with IB, open an IB subaccount for each additional algorithm.
If you can't log in to TWS with your credentials, contact IB. If you can log in to TWS but can't log in to the deployment wizard, contact us and provide the algorithm ID and deployment ID.
SMS 2FA
Our IB integration doesn't support Two-Factor Authentication (2FA) via SMS or the Online Security Code Card. Use the IB Key Security via IBKR Mobile instead.
System Resets
If your IB account has 2FA enabled, you receive a notification on your IB Key device every Sunday to re-authenticate the connection between IB and your live algorithm. When you deploy your algorithm, you can select a time on Sunday to receive the notification. If you don't re-authenticate before the timeout period, your algorithm quits executing. Ensure your IB Key device has sufficient battery for the time you expect to receive the notification. If you don't receive a notification, see I am not receiving IBKR Mobile notifications on the IB website.
Deploy Live Algorithms
You must have an available live trading node for each live trading algorithm you deploy.
Follow these steps to deploy a live algorithm:
- Open the project that you want to deploy.
- Click the
Deploy Live icon.
- On the Deploy Live page, click the Brokerage field and then click from the drop-down menu.
- Enter your IB user name, ID, and password.
- In the Weekly Restart UTC field, enter the Coordinated Universal Time (UTC) time of when you want to receive notifications on Sundays to re-authenticate your account connection.
- Click the Data Provider field and then click one of the data feeds from the drop-down menu.
- If you have subscriptions to IB data feeds and want to use them, click the Data Provider field and then click from the drop-down menu.
- Click the Node field and then click the live trading node that you want to use from the drop-down menu.
- (Optional) Set up notifications.
- Configure the Automatically restart algorithm setting.
- Click .
Your account details are not saved on QuantConnect.
For example, 4 PM UTC is equivalent to 11 AM Eastern Standard Time, 12 PM Eastern Daylight Time, 8 AM Pacific Standard Time, and 9 AM Pacific Daylight Time. To convert from UTC to a different time zone, see the UTC Time Zone Converter on the UTC Time website.
If your IB account has 2FA enabled, you receive a notification on your IB Key device every Sunday to re-authenticate the connection between IB and your live algorithm. If you don't re-authenticate before the timeout period, your algorithm quits executing.
The following table describes the available data feeds:
Data Feed | Description |
---|---|
QuantConnect | Use data collected across all of the exchanges. For more details about this data feed, see Data Feeds. |
IB | Use data sourced directly from IB. For more details about this data feed, see the IB data feed guide. |
QuantConnect + IB | Use a combination of the QuantConnect and IB data feeds. For more details about this option, see Hybrid QuantConnect Data Feed. |
If you use IB data feeds and trade with a paper trading account, you need to share the data feed with your paper trading account. For instructions on sharing data feeds, see Account Types.
By enabling automatic restarts, the algorithm will use best efforts to restart the algorithm if it fails due to a runtime error. This can help improve the algorithm's resilience to temporary outages such as a brokerage API disconnection.
The deployment process can take up to 5 minutes. When the algorithm deploys, the live results page displays. If you know your brokerage positions before you deployed, you can verify they have been loaded properly by checking your equity value in the runtime statistics, your cashbook holdings, and your position holdings.