How to Export Your IBKR Flex Query XML for Tax Calculation
To calculate your taxes using Active ACB, you need to export your trading activity from Interactive Brokers as a Flex Query XML file. Follow these steps carefully.
Log In to IBKR Client Portal
Go to interactivebrokers.com and log in to your account using your username and password. Make sure the toggle is set to Live, not Paper.
Navigate to Flex Queries
Once logged in, look at the top navigation bar. Hover over Performance & Reports. A dropdown menu will appear. Click on Flex Queries, which is the third option in the dropdown.
Create a New Activity Flex Query
You will now see the Flex Queries page. Under the Activity Flex Query section, click the + button in the top-right corner of that panel to create a new custom flex query.
Name Your Query and Select Sections
A large configuration page will open titled Activity Flex Query Details. In the Query Name field, enter any name you like, for example TaxQuery.
Below the name field you will see a Sections area with many report categories listed in two columns. Select each of the following sections:
- Cash Report
- Cash Transactions
- Change in Dividend Accruals
- Change in NAV
- Corporate Actions
- Deposits on Hold
- Forex P/L Details
- Interest Accruals
- Open Positions
- Option Exercises, Assignments and Expirations
- Realized and Unrealized Performance Summary in Base
- Trades
- Transaction Fees
Click on each section one at a time to select it.
Configure Each Section's Fields
When you click on any of the selected sections, a popup dialog will open showing the available fields for that section. For each section, check Select All at the top to include every field, then click Save. Repeat this for every section you selected in Step 4.
Review Delivery Settings and Save
After configuring all sections, scroll down to the delivery configuration options. Leave the defaults as follows:
- Models
- Optional
- Format
- XML
- Period
- Year to Date
- Date Format
- yyyyMMdd
- Time Format
- HHmmss
- Date/Time Separator
- ; (semi-colon)
- Profit and Loss
- Default
- Include Offsetting Trade/Cancel Pairs
- No
- Include Currency Rates
- No
- Include Audit Trail Fields
- No
- Display Account Alias in Place of Account ID
- No
- Breakout by Day
- No
Click Continue to save your query. A confirmation window will appear with a green checkmark.
Run Your Flex Query
Navigate back to the Flex Queries page. You should now see your newly created query listed under the Activity Flex Query section. Hover over the arrow icon next to your query and click Run.
Select the Date Range and Download
A dialog box will appear asking you to choose a Period and Format.
Date range for accurate ACB: For the most accurate Adjusted Cost Base under Canadian pooling rules, your Flex Query should cover your full trading history — from when you first started trading, not just the current tax year. The engine processes all years chronologically to compute correct pooled ACB, but only reports dispositions for your selected tax year.
IBKR limits each Flex Query to a rolling 365-day window. If your trading history spans more than one year, you will need to download multiple files and upload them all together.
Example for a 2025 tax return with trading history starting in 2021:
- File 1: Jan 1, 2021 – Dec 31, 2021
- File 2: Jan 1, 2022 – Dec 31, 2022
- File 3: Jan 1, 2023 – Dec 31, 2023
- File 4: Jan 1, 2024 – Dec 31, 2024
- File 5: Jan 1, 2025 – Jan 30, 2026
Upload all files together using the Add another account button on the calculation page. The engine automatically detects and removes duplicate trades from overlapping date ranges — a 1–2 day overlap between files is fine.
If your trading history is very long, you can limit the start date to the earliest position you still held at the beginning of the tax year. For example, if your oldest open position was first purchased in 2022, you can start from Jan 1, 2022.
For complete superficial loss detection: Set the end date of your final file to January 30 of the following year (e.g., Jan 30, 2026 for a 2025 return). If you sold investments at a loss in December, this lets the engine detect January repurchases that would trigger the superficial loss rule under ITA s.54. This step is optional — if you skip it, the report will flag affected December losses with a warning.
Make sure Format is set to XML, then click Run. Repeat for each date range window you need. The XML file will download to your computer.
Upload to Active ACB
Once you have your downloaded XML file(s), return to ActiveACB and upload them using the calculation page. Click Add another account to add multiple files. The engine automatically removes duplicate trades from overlapping date ranges. Your trades, dividends, fees, and all relevant tax data will be parsed automatically.
IBKR accounts with TFSA or RRSP sub-accounts: If your Flex Query covers multiple accounts and includes a registered account (TFSA, RRSP, RRIF, or FHSA), enter those account IDs in the Registered account IDs to exclude field on the upload page before calculating. Your IBKR account ID appears in the top-right corner of Client Portal (e.g., U1234567). Registered account trades and income are not taxable and should not appear in your tax report.