Interactive Brokers data and setup · 5 min read
IBKR Flex Query: how to set one up to export trade history
To export your Interactive Brokers trade history, create an Activity Flex Query in Client Portal. Open Performance & Reports → Flex Queries, click + next to Activity Flex Query, add the Trades section and save. Then run it from the list, or switch on the Flex Web Service so an app can fetch it with a token.
A Flex query reaches back to the start of the fourth calendar year before this one, so to 1 January 2022 in November 2026. IB’s steps here are as of November 2026, from its Flex Queries guide. IB moves its menus now and then, so the names below matter more than where they sit.
Create the Activity Flex Query
These steps follow IB’s guide to creating an Activity Flex Query. The sections and settings are the ones a trade journal needs, Limitless Workstation’s included.
- Log in to Client Portal and open Performance & Reports → Flex Queries. You can also click Menu at the top left, then Reporting → Flex Queries.
- Click + at the top right of Activity Flex Query and give the query a name, such as “Trade journal”.
- Under Sections, click each section below. In the window that opens, pick the options listed, tick Select All and click Save.
- Account Information
- Net Asset Value (NAV) in Base, your account’s value at the end of each day
- Cash Transactions, with Deposits & Withdrawals and the level Detail
- Trades, with Execution
- Transfers, with the level Detail, if you move money or positions between accounts
- Under Delivery Configuration, set Format to XML and Period to Last 365 Calendar Days. Pick CSV instead if the file is for a spreadsheet.
- Under General Configuration, keep the date format yyyyMMdd, the time format HHmmss and the separator ;, which are IB’s defaults. Set Display Account Alias in Place of Account ID, Include Offsetting Trade/Cancel Pairs and Breakout by Day to No.
- Click Continue, then Create. Note the Query ID shown next to the query in the list.
Without Cash Transactions, a journal can’t tell a deposit from a profit. Keep the date format too: Limitless Workstation reads dates month first, so with dd/MM/yyyy a trade on 3 April would land on 4 March.
Run it once for a file
To download the history yourself, click the blue Run arrow next to the query, choose the period and format, and click Run. IB’s guide to running a Flex Query has the multi-account options.
Switch on the Flex Web Service for automatic imports
An app that imports your history on its own needs a token and the query ID. IB’s guide to configuring the Flex Web Service:
- Open Performance & Reports → Flex Queries → Flex Web Service Configuration, the gear icon.
- Switch the service on.
- Under Should Expire After, pick the longest time offered. IB’s default is 6 hours, and the imports stop when the token expires.
- Leave Valid For IP Address empty. A token tied to one IP address fails from any other, such as your laptop on a different network.
- Click Generate New Token and copy it. A new token turns the previous one off.
The token can only read your reports. It can’t place orders.
For today’s trades: a Trade Confirmation query
An Activity statement covers up to the previous business day. For today’s fills, add a second query under Trade Confirmation Flex Query: the section Trade Confirmations with Executions, format XML, period Today, and the same date and time settings as above. IB’s guide to Trade Confirmation Flex Queries has the rest. This one is optional.
How far back your history goes
IB keeps saved Flex data for the current calendar year and the four before it. Here is what that means on 17 November 2026:
| Account opened | Flex history starts | Not in Flex |
|---|---|---|
| June 2024 | June 2024 | Nothing |
| January 2022 | January 2022 | Nothing |
| March 2019 | 1 January 2022 | March 2019 to December 2021 |
On 1 January 2027 the window moves on, and 2022 drops out. Keep a copy of older statements if you want them for your records. A Flex Web Service request covers at most 365 days, so an app fetches five years one year at a time.
Deposits aren’t profit: one day worked through
A journal that reads your daily account value has to take deposits out, or a new deposit looks like a great day. Say your account closes Monday at USD 50,000. On Tuesday you deposit USD 10,000, and the account closes at USD 61,200.
| USD | |
|---|---|
| Monday’s close | 50,000 |
| Tuesday’s deposit | 10,000 |
| Tuesday’s close | 61,200 |
| Change in account value | 11,200 |
| Tuesday’s profit, change minus deposit | 1,200 |
| Return, 1,200 ÷ (50,000 + 10,000) | 2.0% |
That is why the query needs Cash Transactions with Deposits & Withdrawals. Without it, Tuesday shows USD 11,200 of profit and a return of 22.4%.
Importing it into Limitless Workstation
Limitless Workstation reads your history from IB Flex, because IB’s connection gives it only today’s trades. The app has the whole setup as a checklist in Settings (Ctrl+,) → Connection → Interactive Brokers → Account history → IB Flex. Each value has a Copy button, and Open Flex Queries in Client Portal takes you to IB’s page. Until Flex is set up, both performance widgets show a banner whose Set up… button opens that page.
Paste the token and the query IDs, then click Save & import now. Spaces in the token are dropped. A query ID field also takes a Flex link or text such as “Query ID: 123456” and keeps the number.
- The first import fetches the most recent year first, then works back a year at a time to the start of what Flex keeps. A long history takes a few minutes.
- After that it imports once a day. The Trade Confirmation query runs every 5 minutes while the app is open, and F5 in either performance widget imports now.
- Deposits, withdrawals and transfers stay out of your profit, as in the example above. Show deposits & transfers marks each one on the charts and the calendar.
- A trade IB cancels later is taken out of your history again.
- Everything stays on your computer, the token included, with no copy in a cloud.
- An expired token is reported in the status line, in the Messages widget and in both performance widgets. Generate a new one and paste it in.
With the history in, Day trade performance and Account performance cover the days before you first ran the app. The Performance page lists what each one shows.
Next: make sense of the numbers
A full history gives you a win rate and a profit factor worth reading. Trading performance metrics: win rate, profit factor explains what each one tells you and when it misleads.
Answers to common questions
How far back does an IBKR Flex Query go?+
To the start of the fourth calendar year before this one. In November 2026 that is 1 January 2022, as of IB’s Flex Queries guide. Older trades aren’t in Flex.
How long does an IBKR Flex Web Service token last?+
As long as you choose when you generate it. IB’s default is 6 hours, so an app stops getting reports the same day unless you pick a longer expiry. Generating a new token turns the old one off.
Can I export my IBKR trade history to CSV?+
Yes. Set the Flex query’s format to CSV, then click the blue Run arrow next to it under Performance & Reports → Flex Queries. IB offers XML, CSV and two text formats.
Why does my IBKR connection show only today’s trades?+
The connection that TWS and IB Gateway give other apps carries only today’s trades and no account history. Past trades and daily account values have to come from a Flex query.
Do I need Flex on cTrader?+
No. On cTrader, Limitless Workstation brings in your past trades and daily balances each time you connect, the last 90 days the first time.
Get Limitless Workstation
Limitless Workstation is a desktop trading app. It runs on Windows, macOS and Linux.
You trade through Interactive Brokers or through cTrader, one broker at a time.