Interactive Brokers exports trades through a Flex Query: a saved report you set up once in IBKR and run whenever you want a file. Drop the file on the Brokers page and it is recognised as Interactive Brokers.
Setting up the query
- Log in to IBKR's Client Portal, open Performance & Reports → Flex Queries and create an Activity Flex Query.
- In the Trades section choose Execution, select all fields, and save the section.
- Set Format to CSV. XML is IBKR's default, and we can't read it.
- Date format
yyyyMMdd, time formatHHmmss, separator;(semi-colon) are recommended. Other date settings work too. - Save, run the query for the period you want, and download the file.
A query covers at most 365 days. For older trades, run it once per year and import each file.
Positions opened before the query's start date
If a position was already open on the first day of the query, its opening fill isn't in the file, so we can't know its entry price. That trade is left out rather than guessed. Fills that close it are ignored, and the rest of the file imports normally. To bring it in, run the query from a date before you opened it.
A position IBKR closed at a price of 0 (for example an option that expired worthless) is imported as closed at 0, the same way IBKR reports it.
Paper trading accounts
Paper trades import the same way as live ones. IBKR gives a paper account its own login (its account number starts with DU), so create and run the Flex Query while you're signed in with the paper login. A query run from your live login reports live trades only.
If the file is refused
- “This is the XML version of a Flex Query”: edit the query, change Format to CSV, and run it again.
- “This does not look like an IBKR file”: the Trades section has to include at least Symbol, Buy/Sell, Date/Time (or TradeDate), Quantity and Price. Selecting all fields covers this.
- “No trades found”: the period you ran had no buys or sells. Check the date range, and that you ran the query from the right login (paper or live).
- Don't open and re-save the file in Excel or Numbers before importing. They can rewrite the dates.
Fixed 5 Oct 2026: some Flex Query files were refused even though they were set up correctly. This affected files that use IBKR's older column names (TradePrice, IBCommission, DateTime), files without the account ID column, files with header and trailer records switched on, and files with more than one section. All of these now import. The same fix stops positions opened before the query's start date from turning into made-up trades in the opposite direction. If a file was refused before, import it again. Trades that already came in are recognised as duplicates and skipped.
Prefer not to export files? Interactive Brokers can also be connected for automatic sync on the Essential and Pro plans.