Guide

Sync Interactive Brokers with a Flex Query

Interactive Brokers syncs through a Flex Query: you build a report in IBKR, and Alpha Journey pulls it with a read-only token. Menu names can differ slightly between IBKR accounts.

Last updated

What you get: a daily import

IBKR refreshes Flex data once a day, at close of business. Sync runs daily and does not show live trades. A trade shows up after IBKR's next daily refresh.

Step 1: create an Activity Flex Query

In IBKR Client Portal go to Performance & Reports > Flex Queries > Activity Flex Query > Create. Add the Trades section and choose Execution-level detail (Executions). Select the fields listed below. Set the format to XML, the date format to yyyy-MM-dd, the time format to HH:mm:ss and the time zone to UTC where IBKR offers it. For the period, pick Last 365 calendar days, or the longest range IBKR allows. Save the query and note the Query ID shown afterwards.

Step 2: enable the Flex Web Service

Go to Performance & Reports > Settings and find Flex Web Service. Enable it and generate a token. Pick an expiry between 6 hours and 1 year. The token has to be renewed when it expires, and Alpha Journey shows a reconnect prompt when that happens. You can also restrict the token to one IP address.

Step 3: connect in Alpha Journey

Open Settings > Exchanges > Interactive Brokers and paste the token and the Query ID. The first sync imports the period your query covers.

Troubleshooting

An expired or invalid token needs a new token from the Flex Web Service settings. An IP restriction blocks requests from addresses not on the list, so clear it or add the server IP. If the report is still generating, IBKR has not finished building it. Try again in a few minutes. Paper-trading accounts generally have no Flex Web Service, so import their trades by CSV.

CSV alternative

Run the same Flex Query with CSV as the format, then upload the file on the Imports page. Alpha Journey recognises the Interactive Brokers Flex CSV and skips column mapping.

Fields to include in the Trades section

  • TradeID, IBExecID, Conid
  • Symbol, Description, AssetClass, Exchange
  • Currency, Multiplier
  • UnderlyingSymbol, Expiry, Strike, Put/Call (options and futures)
  • DateTime, or TradeDate plus TradeTime
  • Buy/Sell, Quantity, TradePrice
  • IBCommission, IBCommissionCurrency
  • FifoPnlRealized, OpenCloseIndicator, TransactionType