Interactive Brokers
How to export an Activity Flex Query in XML format
1Create the Flex Query
- 1.Log in to Client Portal at Interactive Brokers.
- 2.Go to Performance & Reports → Flex Queries.
- 3.Click Create → Activity Flex Query and give it a name, for example "Taxify".
2Enable these sections
Enable all sections below – and no more. For each section, open the list of the fields to tick in it (the pencil icon in IB).
Trades
All buys and sells – the base of the full calculation.
Set levelOfDetail to EXECUTION, not ORDER. If not, partial fills merge into one row and the FIFO matching becomes less accurate.
Show the fields (39)
Tick at least these fields. More fields do no harm.
accountIdcurrencyassetCategorysymboldescriptionconidisinlistingExchangeunderlyingConidunderlyingSymbolmultiplierstrikeexpiryputCalltradeIDibExecIDextExecIDdateTimereportDatebuySellquantitytradePriceproceedstaxesibCommissionibCommissionCurrencynetCashcostfifoPnlRealizedibOrderIDtransactionIDtradeDatesettleDateTargetopenCloseIndicatorlevelOfDetailorderTypeisAPIOrdertransactionTypenotesCash Transactions
Dividends, withholding tax, interest and fees. IB has no separate "Dividends" or "Withholding Tax" section – these are values in this section.
Show the fields (17)
Tick at least these fields. More fields do no harm.
accountIdcurrencyassetCategorysymboldescriptionconidisinlistingExchangedateTimesettleDateamounttypetradeIDcodetransactionIDreportDateclientReferenceCorporate Actions
Splits, mergers and spin-offs that change the acquisition price.
Show the fields (16)
Tick at least these fields. More fields do no harm.
accountIdcurrencyassetCategorysymboldescriptionconidisinreportDatedateTimequantityproceedsvalueamounttypetransactionIDcodeOption Exercises, Assignments and Expirations
How the option positions closed – exercise, assignment or expiration.
Show the fields (23)
Tick at least these fields. More fields do no harm.
accountIdcurrencyassetCategorysymboldescriptionconidisinlistingExchangeunderlyingConidunderlyingSymbolmultiplierstrikeexpiryputCalldatequantitytradePriceproceedscostBasisrealizedPnlmtmPnltransactionTypetradeIDOpen Positions
The positions at the end of the period.
Set levelOfDetail to LOT, so that you get each buy of a position. If not, the FIFO state at the end of the year is not correct.
Show the fields (25)
Tick at least these fields. More fields do no harm.
accountIdcurrencyassetCategorysymboldescriptionconidisinlistingExchangeunderlyingSymbolmultiplierstrikeexpiryputCallreportDatepositionmarkPricepositionValueopenPricecostBasisPricecostBasisMoneyfifoPnlUnrealizedlevelOfDetailopenDateTimeholdingPeriodDateTimecodePrior Period Positions
The positions at the start of the period. Without it, older buys have no acquisition price and sells stay unmatched – then you cannot lock the tax return.
Show the fields (14)
Tick at least these fields. More fields do no harm.
accountIdcurrencyassetCategorysymboldescriptionconidisinreportDatedatepriorMtmPnlpositionpriceopenDateTimelevelOfDetailFinancial Instrument Information
The table of the instruments (ISIN, asset class, multiplier). Without it, Taxify can resolve options and asset classes incorrectly.
Show the fields (15)
Tick at least these fields. More fields do no harm.
conidassetCategorysymboldescriptionisincusiplistingExchangecurrencymultiplierstrikeexpiryputCallunderlyingConidunderlyingSymbolissuerTransfers(optional)
Positions transferred between IB accounts. Enable it if you have more than one account.
Show the fields (18)
Tick at least these fields. More fields do no harm.
accountIdcurrencyassetCategorysymboldescriptionconidisinreportDatedatetypedirectionaccountquantitytransferPricepositionAmountcashTransfercodetransactionID3Check the settings
Set these values in Delivery Configuration and General Configuration. Most of them are correct by default.
- Format
- XML
- Date Format
- yyyyMMdd
- Time Format
- HHmmss
- Date/Time Separator
- ; (semi-colon)
- 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
4Run the query and download the statement
- 1.Click the Run icon next to the saved query.
- 2.Set the period: From = the date when you opened the account (or 1 January of the year), To = 31 December of the same year.
- 3.Download the XML file.
- 4.Do this again for each year of the account – one file for each year.
5Upload the statement to Taxify
- 1.In Taxify, open Accounts and select your broker account. If you do not have one yet, create it.
- 2.On the Import trades tab, drop the files into the marked area or select them with the button. Upload every year.
- 3.When the processing is complete, you see the imported trades and you can start the tax calculation.
Tips
- Periods that overlap are not a problem: Taxify finds duplicate trades and skips them.
- If a sell has no matching buy, import earlier years or check the Prior Period Positions section.
- Taxify reads only a Flex Query in XML format. It does not support an Activity Statement in CSV yet.
- You can enter trades from platforms that Taxify does not import yet by hand, in the account detail.