Trade Teardown

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

  1. Log in to the IBKR Client Portal.
  2. Open Performance & Reports → Flex Queries.
  3. 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.

FieldWhat it's for
Date/TimeThe execution time, to the second. Without it, fills can't be lined up with signals.
Buy/Sell, Quantity, Trade PriceDirection, size and fill price
IB CommissionWhat each fill cost, kept apart from slippage
IB Order IDGroups the executions of one order, so a split fill isn't mistaken for a duplicate
IB Execution IDA unique ID for each fill
Open/Close IndicatorWhether a fill opened or closed a position (O, C)
Symbol, Underlying Symbol, Expiry, MultiplierThe contract (MNQH5), its root (MNQ) and its dollar value per point
Asset Class, Account ID, Level of DetailFutures vs other instruments, which account, and execution vs order rows

3. Delivery settings

SettingUse
FormatCSV or XML. Both carry the same data.
Include column headersYes (for CSV)
Include header and trailer records, section codesEither. Files with BOF/HEADER/DATA rows read fine.
Date and time formatThe defaults (yyyyMMdd, HHmmss, separator ;) are fine, as are the ISO options
Include canceled tradesNo

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:

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.

See a sample report