Interactive Brokers

Interactive Brokers is a popular stocks broker for international traders. Automate your trading strategies with TradersPost.

The Interactive Brokers integration is generally available for all TradersPost customers. Please remember that this integration is in BETA and you may experience issues that we have not discovered yet. It is recommended to test with a paper account first. If you have any issues or questions, please email us at [email protected]

Contact Information

Email: [email protected]

Phone: +1 (877) 442-2757

Reliability

The Interactive Brokers API can sometimes be unreliable. You may occasionally receive errors from IBKR that may look like this with a message like "Idle timeout reached". This means we sent a request to the IBKR API and it timed out after waiting 5 seconds for a response.

On average, the IBKR API responds to our requests in 229 milliseconds.

Supported Asset Classes

The IBKR WebAPI only supports the stocks asset class. While the broader IBKR platform does support other asset classes, the WebAPI that we are integrated with only supports stocks. It is unknown when IBKR will remove this limitation and allow other asset classes.

Automating Interactive Brokers stock orders

Interactive Brokers works differently from most connections. It lives inside a login session, it takes one order at a time, and it has a nightly reset. Knowing those three things explains almost every problem people hit.

Beta, and no IBKR LITE

Interactive Brokers

  • Beta
  • Generally available
Status

Generally available, still in beta

IBKR LITE accounts

Can connect, no API orders

IBKR LITE accounts can connect, but IBKR will not allow API orders on them.

One username, one session

IBKR allows a username to hold one active session. After you connect, TradersPost pings the session every minute to keep it ready for an alert.

Example The minute positions are an example. A takeover can happen at any point between checks.

  1. 1 Every minute

    TradersPost pings the session

    This keeps the session ready for an alert.

  2. 2 You log in elsewhere

    TWS or the mobile app, same username

    You take the session away.

  3. 3 A signal lands

    TradersPost does not hold the session

    The signal can fail. TradersPost will try to start the session and wait before retrying, but IBKR can be slow.

  4. 4 Next check

    TradersPost takes the session back

    It takes the session back on its next check.

  5. The documented workaround

    A second IBKR username

    Use it only for TradersPost, with access to just the one account you want to trade. Trades across several accounts from one login session are not supported.

One order at a time

IBKR processes one order per account at a time. TradersPost sends simple, bracket and one-triggers-other order classes to IBKR, with market, limit, stop, stop limit and trailing stop order types.

Example Ten orders fired together, each segment is one order.

  1. 1 Together

    A strategy fires ten orders

    They are worked through in sequence, not in parallel.

  2. 2 Last

    The tenth order

    The last one waits for the nine before it.

The nightly reset

IBKR's API has a reset window between 23:45 and 00:45 ET for North America. If your strategy can trade overnight, build in a gap around that window.

Times are Eastern, for North America.

  1. 1 23:45 ET

    The reset window opens

    The API cannot be relied on, and orders sent then can fail even with retries on.

  2. 2 00:45 ET

    The reset window closes

    The session also restarts each night, which matters for quotes below.

Quotes can come from Polygon

TradersPost uses IBKR quotes when it can, and falls back to Polygon market data when it cannot.

  1. 1first

    Used first

    IBKR quotes

    • Used whenever TradersPost can
  2. 2then

    Fallback

    Polygon market data

    • Another session is logged in
    • You lack market data for the exchange
    • IBKR fails or returns delayed data
    • The first quote request for a symbol in a session

Settings that help, and what to expect

  • You send: An order over a confirmation threshold, for example over 100,000 in value

    At IBKR: IBKR asks for confirmation, which can hold up API orders

    Can hold up

    In TWS, under Global Config and Presets, you can zero out the precautionary fields so confirmations do not hold up API orders.

  • You send: A lookup of an older order id

    At IBKR: May show an error

    Today only

    IBKR only exposes today's orders.

What Interactive Brokers supports

Order types and features by asset class, as TradersPost sends them to Interactive Brokers.

What Interactive Brokers supports
Capability Stocks Long and short
Order types
Market orders Yes
Limit orders Yes
Stop orders Yes
Stop-limit orders Yes
Trailing stops Yes
Time in force
Day Yes
Good till canceled Yes
Immediate or cancel Yes
Fill or kill No
At the open Yes
At the close No
Attached exits
Bracket orders Yes
OCO orders No
OTO orders Yes
Trailing stop attached Yes
Direction and size
Short selling Yes
Fractional quantity No

Daily Reset

The IBKR API has a daily "reset" window that occurs between 23:45 and 00:45 ET for the North America region. You can read more about the Interactive Brokers system status here.

Market Data Quotes

The Interactive Brokers API does not have a 100% reliable API for retrieving market data quotes for use with automated trading. In the scenarios where we cannot retrieve a quote from IBKR, we fallback to our Polygon market data provider. We will fallback to Polygon in the following scenarios.

  • If you are logged in to another IBKR session, then we will fallback to Polygon. For example, logging in to the IBKR mobile app or TWS will cause TradersPost to not be able to use your market data. IBKR market data can only be used in one active session at a time.
  • If you don't have market data in IBKR for the exchange being requested.
  • If the IBKR API fails when fetching a quote from it.
  • If it is the first request for a quote from IBKR for that symbol during the current session. Sessions are active for 24 hours and are restarted every night due to the IBKR Daily Reset. Subsequent requests for the same symbol in the same session will return data from IBKR and we will use that data if it exists, otherwise it will fallback to Polygon.
  • If IBKR returns a quote but the data is delayed, we will fallback to Polygon.

Paper Account

Some paper IBKR accounts have trouble connecting to TradersPost and may receive the message "This username is not associated with a paper trading account" when trying to connect with TradersPost.

You will need to follow these steps to fix your IBKR paper account:

  • Login to your live client portal and go to Settings.
  • Under settings go to Paper Trading Account.
  • Find your paper trading username and complete a password reset for a new paper trading password.

Then you will be able to connect your IBKR paper account to TradersPost.

TWS Precautionary Settings

Interactive Brokers by default requires order confirmations under certain conditions. For example, if the order total value is greater than $100000, the order will require a confirmation before being able to submit the order. These confirmations can slow down trade execution and can increase the likelihood that something fails. IBKR recommends turning off these precautionary settings.

You can do this by logging into TWS and going to Global Config > Presets > Stocks (or whatever other asset class).

You can put 0s in all fields to disable them, and then those precautionary confirmation messages won't be required when submitting orders through the IBKR API via TradersPost.

User Login Sessions

To avoid session conflicts with other IBKR clients, create a 2nd username that is dedicated for use with TradersPost. Read about adding a user in the IBKR documentation to get your 2nd user setup. Make sure that the dedicated user you create in IBKR only has access to the one account you want to trade within TradersPost. TradersPost and IBKR does not support executing trades across multiple different accounts from one user login session.

Historical Orders

The Interactive Brokers API only has the ability to view todays orders so we are not able to show historical orders within TradersPost. This means you may have issues viewing historical trades as well, since we are unable to pull order data for older order ids. You will get an error when viewing old order ids that says something like this.

Idle timeout reached for "https://api.ibkr.com/v1/api/iserver/account/order/status/519256816".

IBKR LITE Accounts

Unfortunately, the IBKR WebAPI does not support IBKR LITE accounts. You will be able to connect your account to TradersPost, but they will not allow orders to be created. We have no way to identify if your account is a LITE account or not to notify you when you connect to TradersPost. You will only see a message when trying to create an order that says "API orders are not allowed for lite accounts".

Interactive Brokers automation questions

Can I automate IBKR futures with TradersPost?
Not through this connection. The IBKR WebAPI used by TradersPost supports stocks only. For futures automation, use a futures connection such as Tradovate, TradeStation, tastytrade, or ProjectX.
Why did an IBKR order time out?
The IBKR API sometimes returns idle-timeout or session errors. Check that TradersPost still owns the login session and that you are outside the daily reset window, then retry from the trade log.