Connect Interactive Brokers
IBKR is VEXA's most complete integration. Which Flex Query ID goes where, what the Activity and Trade Confirmation queries each do, and how to set up both.
On this page
What this does
Interactive Brokers is the broker VEXA supports most completely: an API sync you run whenever you want it, a file import, multi-account handling, and a duplicate-removal tool none of the other brokers have.


Two Flex Queries: which ID goes where
The API sync can use two Flex Queries from IBKR. Both use the same Flex token.
| Activity Flex Query | Trade Confirmation Flex Query | |
|---|---|---|
| Goes in the VEXA field | Activity Flex Query ID (required) | Trade Confirmation Query ID (optional) |
| What it brings in | Your full trade history, up to the last 365 days | Today’s trades only |
| How fresh it is | IBKR updates it once a day after the market closes, so today’s trades arrive the next day | IBKR adds each trade about 5 to 10 minutes after it fills. Press Sync now to bring it in (VEXA also syncs on its own twice a day) |
We recommend both: Activity for your history, Trade Confirmation for same-day trades. If you leave the Trade Confirmation field blank, the sync uses the Activity query alone and today’s trades arrive the next day.
Set up the API sync, step by step
Build the queries in a desktop browser. IBKR’s Flex Query editor is a wide form and is hard to use on a phone. Once you have the IDs you can paste them into VEXA on any device.
1. Get your Flex token
- In IBKR’s Client Portal, open Performance & Reports > Flex Queries.
- Next to Flex Web Service Configuration, click the settings icon.
- Tick Flex Web Service Status.
- Set Expire After to one year. IBKR allows anything from 6 hours to a year; a short expiry works today and stops the sync later.
- Leave the IP restriction empty. A token limited to certain IP addresses can’t be used by VEXA.
- Click Generate a new token, save, and copy the Current Token.
2. Create the Activity Flex Query (required)
- On Flex Queries, click + next to Activity Flex Query and name it, for example “VEXA”.
- Under Sections, choose Trades, then Executions, and select all fields.
- Set Format to CSV and Period to Last 365 Calendar Days. Set Include Column Headers to Yes, and Include Header and Trailer Records, Display Single Column Header Row and Include Section Code and Line Descriptor to No.
- Set Date Format to
yyyy-MM-dd, Time Format toHH:mm:ss, and Date/Time Separator to a single space. - Leave Profit and Loss at Default, and set No for Include Cancelled Trades, Include Currency Rates, Include Audit Trail Fields, Display Account Alias in Place of Account ID, and Breakout by Day.
- Save. Click the info icon next to the query and copy its Query ID. Run it once in IBKR to check it returns your trades.
Full detail: Set up an IBKR Activity Flex Query.
3. Create the Trade Confirmation Flex Query (optional, for same-day trades)
- On Flex Queries, click + next to Trade Confirmation Flex Query and name it, for example “VEXA Today”.
- Under Sections, choose Trade Confirmations and select all fields.
- Set Format to CSV and Period to Today.
- Use the same date and time settings as the Activity query:
yyyy-MM-dd,HH:mm:ss, a single space. - Save. Click the info icon next to the query and copy its Query ID.
Make a separate query for this. Don’t reuse a Trade Confirmation query you built for manual upload: that one uses different date settings and a period of months.
4. Enter them in VEXA
- Open the Interactive Brokers connection page in VEXA.
- Paste the token into Flex Token, the Activity Query ID into Activity Flex Query ID, and the Trade Confirmation Query ID into Trade Confirmation Query ID. Leave the last one blank if you skipped step 3.
- Save. The first sync starts straight away.
Manual CSV upload
Manual upload supports an original execution-level Activity Flex CSV containing Trades executions, or a Trade Confirmation Flex CSV with the required fields.
| You want | Report | Guide |
|---|---|---|
| Manual CSV import | Execution-level Activity Flex CSV or Trade Confirmation Flex CSV | Activity Flex setup or Trade Confirmation export |
A summary Activity Statement is different: it does not supply the execution report required for reconstruction. Keep the original CSV and its account, instrument, execution, time, price, quantity and fee fields. Public manual-upload controls require the supported CSV format; do not assume an XML report can be selected.
Your connection and account data
Your IBKR connection details and imported trading data are synced to your VEXA account and used by the server connection service; they are not stored only on the device where you entered them. Keep your Flex token private. Broker imports use read-only access. Where available on a supported desktop connection, optional desktop Enforce mode can cancel or reduce orders and close or reduce positions under rules you approve. It requires separate consent and never opens or adds to a position. It cannot guarantee an action before a fill.
Before you start
- You need the Master Account, the one whose id starts with
U. Flex Web Service is configured there. - The API sync reaches the last 365 days, rolling. The file export can reach all of your history, so most people set up both: the sync for going forward, one file for the backfill.
- When you generate the Flex token, set Expire After to a year. A short expiry works today and fails silently in a few months.
- Stocks, options, futures, forex and crypto are all supported.
Which one to set up first
Set up the API sync. Once the token is saved, updating your trades is one tap rather than another export.
Then, if you want history older than a year, build the Trade Confirmation query, choose a period of All, and upload the file once. The overlap between the two is discarded, so there is nothing to be careful about.
Multiple IBKR accounts
Upload a file covering several IBKR accounts and VEXA splits it by account id and creates one VEXA account for each. You do not need to export them separately.
One setting breaks this: Display Account Alias in Place of Account ID. Leave it set to No. With aliases in place of ids, VEXA cannot tell the accounts apart.
Limits and gotchas
- XML will not upload. IBKR offers CSV, XML and HTML. Manual upload reads CSV. An XML file produces “No valid executions found in file after parsing and validation”.
- Choose the Trade Confirmations section, then tick all of its fields. Leave fields out and the upload stops on the columns it cannot find, which leaves VEXA nothing to reconstruct.
- The rolling window re-delivers old fills. IBKR hands back the same 365 days every time it is asked. VEXA keeps a registry of fills it has already consumed and filters them out. If you ever see a position with an impossible size, that machinery is what to mention when you report it.
- SPLG now reports as SPYM. IBKR’s ticker transition is applied globally so both sides of the change net into one position. Your old SPLG trades appear under SPYM. Nothing is lost.
- Flex data older than a week triggers a staleness warning in the sync. It means your query period is too narrow. Set it to Last 365 Calendar Days.
What you should see
After connecting the sync: the account shows an Active badge, and a first pull runs immediately. On a busy account the first sync takes a minute or two.
After uploading a file: a result panel naming the detected format, with counts. Multi-account files produce more than one account in your broker list.
If it doesn’t work
- The upload says no valid executions were found. Check for a summary Activity Statement, unsupported XML upload, missing required fields or an empty execution range. A supported execution-level Activity Flex CSV is valid; it is not the same as a summary statement.
- The account shows Action needed. The sentence under it says what IBKR reported: an expired or rejected Flex token, a Query ID IBKR doesn’t recognise, or a statement IBKR hasn’t produced for over a day. See Reconnect a broker for each one.
- Today’s trades are missing. Without a Trade Confirmation Query ID, today’s trades arrive after IBKR’s next daily update. Add the Trade Confirmation query (step 3 above) for same-day trades.
- You see the same trade twice. IBKR is the one broker with a repair button. See Remove duplicate trades.
Broker page
Related
Still stuck? Email support@vexatrade.ai.