Guide · 3 min read
How to export your IBKR trades with a Flex Query
A Flex Query is Interactive Brokers' configurable report. Set one up once, and from then on a single click exports every execution for any date range as CSV or XML.
You need a Flex Query, not the regular Activity Statement. The statement is built for reading, and its trades come rolled up per order without execution IDs. A Flex Query can list every single execution with its exact time.
IBKR moves menus around from time to time. If a name below doesn't match what you see, look for "Flex Queries" under Performance & Reports or Reports.
1. Create the query
- Log in to the IBKR Client Portal.
- Open Performance & Reports → Flex Queries.
- Next to Activity Flex Query, click + to create one, and give it a name such as
Trades for reconciliation.
2. Add the Trades section
Click Trades. Under its options, tick Executions, which gives one row per fill. Orders is optional. Closed Lots, Symbol Summary and Wash Sales aren't needed.
Then tick these fields. Extra fields do no harm, so Select All also works.
| Field | What it's for |
|---|---|
| Date/Time | The execution time, to the second. Without it, fills can't be lined up with signals. |
| Buy/Sell, Quantity, Trade Price | Direction, size and fill price |
| IB Commission | What each fill cost, kept apart from slippage |
| IB Order ID | Groups the executions of one order, so a split fill isn't mistaken for a duplicate |
| IB Execution ID | A unique ID for each fill |
| Open/Close Indicator | Whether a fill opened or closed a position (O, C) |
| Symbol, Underlying Symbol, Expiry, Multiplier | The contract (MNQH5), its root (MNQ) and its dollar value per point |
| Asset Class, Account ID, Level of Detail | Futures vs other instruments, which account, and execution vs order rows |
3. Delivery settings
| Setting | Use |
|---|---|
| Format | CSV or XML. Both carry the same data. |
| Include column headers | Yes (for CSV) |
| Include header and trailer records, section codes | Either. Files with BOF/HEADER/DATA rows read fine. |
| Date and time format | The defaults (yyyyMMdd, HHmmss, separator ;) are fine, as are the ISO options |
| Include canceled trades | No |
Save the query.
4. Run it
On the Flex Queries page, click Run next to your query, pick the date range and format, and download the file. Next time, it's just this step.
Pick the same dates as the TradingView export you'll compare it with. A day either side does no harm.
What the file looks like
A CSV starts with a header row such as:
"ClientAccountID","AssetClass","Symbol","UnderlyingSymbol","Multiplier","Expiry","DateTime","Quantity","TradePrice","IBCommission","Open/CloseIndicator","Buy/Sell","IBOrderID","IBExecID","LevelOfDetail"
Some things that surprise people:
- Sells have a negative quantity (
-2withSELL), and commission is negative because it's a charge. - One order can have several rows when it filled in pieces. They share an IB Order ID.
- Cancelled corrections show as
BUY (Ca.)orSELL (Ca.). - Date formats follow your settings:
20250203;093000,2025-02-03;09:30:00and03/02/2025;09:30:00are all possible.
Which time zone are the times in?
The file doesn't say, and IBKR's documentation doesn't either. Most tools that read Flex files treat the times as US Eastern (New York), but that's an assumption. The way to be sure is to compare one fill's time in the file with the same fill in TWS or the Client Portal's trade history.
If every fill in a comparison looks shifted by the same whole number of hours, the zone is the cause.
What you don't need
A Flex Query file contains your executions, not your login. Checking fills against a strategy needs only the downloaded file. There's no need for a Flex Web Service token, an API key or a broker connection.
Trade Teardown reads this file in your browser, together with TradingView's List of trades, and lines them up trade by trade. If the times look shifted, it tells you which zone lines them up.