← Back

How to Export Your IBKR Flex Query XML for Tax Calculation

The ACB calculator reads the Flex Query XML file that Interactive Brokers produces. You set up the Flex Query once, which takes about 10 minutes. After that you run it to download your files and upload them to ActiveACB. The adjusted cost base guide explains the rules the calculator applies.

By Published Last reviewed

Controls to click or set are outlined in red. Click any screenshot to see it full size.

Part 1 · One time

Set Up Your Flex Query

  1. Log in to Client Portal at interactivebrokers.com. Important: the switch outlined in red must be on Live, not Paper.

    IBKR login page with the Live and Paper switch outlined in red
  2. Hover over Performance & Reports in the top menu.

  3. Click Flex Queries, the third item in the dropdown and outlined in red.

    Top menu with Performance and Reports and the Flex Queries item outlined in red
  4. Click the + button outlined in red in the Activity Flex Query panel.

    Flex Queries page with the plus button in the Activity Flex Query panel outlined in red
  5. Type a name such as TaxQuery in Query Name.

  6. Open the first of these 13 Sections, outlined in red. Each opens a list of fields.

    • 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
    Activity Flex Query Details with the query name and the 13 checked sections outlined in red
  7. Tick Select All, outlined in red at the top of the field list.

    Section field list with Select All and the Save button outlined in red
  8. Click Save at the bottom of the field list. Repeat steps 6 to 8 for the remaining sections. Each completed section shows a check mark.

  9. Check the settings below the sections against this table. Important: Format, outlined in red, must be XML.

    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
    Delivery and general settings with Format set to XML and the Continue button outlined in red
  10. Click Continue at the bottom of the settings page to review your query.

  11. Click Create on the review page to save the query. A Complete message with a green check mark confirms it is saved.

  12. Click Ok, outlined in red, to return to your saved queries.

    Complete confirmation with the Ok button outlined in red
Part 2 · Each time you file

Run the Query and Download Your Files

  1. Click the Run arrow outlined in red beside your query on the Flex Queries page.

    Saved TaxQuery with the Run arrow outlined in red
  2. Choose a custom date range in Period. Use no more than 365 days per file. Important: start with the year you first traded so earlier purchases are included.

  3. Set Format to XML, outlined in red. The screenshot shows the default Period setting before you choose your dates.

    Run dialog with Period, Format and the Run button outlined in red
  4. Click Run to download the XML file.

  5. Repeat steps 1 to 4 for the remaining date ranges through your tax year. See the date-range example below for leap years and January repurchases.

Check your files. Each download should end in .xml. Together, the files should cover your history without gaps. A day or two of overlap is fine. Duplicate trades from overlapping ranges are removed automatically.

Part 3

Upload to ActiveACB

Important: if your files include registered accounts, follow the account exclusion instructions below before calculating.

  1. Open the calculator.

  2. Add all your XML files with + Add files. Uploading more than one file in a calculation requires season access.

  3. Run the calculation. Your trades, dividends, fees and other tax data are read automatically.

If a row needs a correction, the trade editor on the results page lets you fix, add or delete rows and recalculate without uploading again.

Broker Reconciliation, IBKR only: your results include a Broker Reconciliation section that compares IBKR's own realized P&L for each symbol against the engine's Schedule 3 figure, with each difference explained (FX method, superficial losses, return of capital, options, short sales). It appears on the results page, in your history, and in the PDF report.

If This Applies to You

Why start from your first trade. Your adjusted cost base depends on earlier purchases and adjustments, so one year of trades may not be enough for holdings bought earlier. The engine processes every year in order to work out your opening positions and opening foreign-cash balances, then reports only the sales in the tax year you pick.

Traded only in Canadian dollars? If you never held US-dollar cash, you can start at the earliest purchase of anything you still held at the start of the tax year. If you traded in USD, keep the full history so your foreign-currency gains under s.39(2) start from the correct balances.

Sold at a loss in December? Important: add a file covering January 1 to January 30 of the next year. This lets the engine see January repurchases that would make the loss a superficial loss under ITA s.54. If you skip this, the report flags the affected December losses with a warning.

More than one IBKR account? A Flex Query that covers several accounts works as one file. Every account statement inside it is read, and overlapping rows are counted once.

Files include registered accounts? Before calculating, enter any TFSA, RRSP, RRIF or FHSA account IDs in Additional registered account IDs to exclude. Your account ID is in the top-right corner of Client Portal, for example U1234567. Registered account trades and income are not taxable and stay out of your report.

More than 365 days of history?

Split the download into ranges of no more than 365 days each. For a 2025 return with trading that began in 2021, use the following files. The leap year is split into two files, and the optional January file is separate.

Prefer ActiveACB in your Google results. Add activeacb.ca as a preferred source and Google shows you more of our tax guides in your own search results.

Add ActiveACB in Google
Upload Your Flex Query →