United StatesBroker
Interactive Brokers statements: how to export them and turn them into clean data
Updated 11 November 2026 · Last checked 11 November 2026
Interactive Brokers does not hand you a bank-style monthly statement for cash. The record of every cash movement, with a running balance, comes from a Flex Query that you define once in the Client Portal and run whenever you need it. Selfirm reads the Statement of Funds section of that query, exported as XML.
What Interactive Brokers provides, and what Selfirm reads
| File | Format | In Selfirm |
|---|---|---|
| Activity Flex Query, Statement of Funds section | XML | Read |
| Activity Flex Query, other sections (trades, positions, and so on) | XML | Not read |
| Activity Statement (default or custom) | PDF, CSV | Not read |
How to export the Statement of Funds
These steps follow IBKR’s Client Portal guides for Activity Flex Queries and for running a Flex Query, checked on 11 November 2026. IBKR changes its portal often, so the wording on screen may differ a little.
Create the query once
- In the Client Portal, go to Performance & Reports > Flex Queries. If you manage several accounts, pick the account in the account selector first.
- Click the plus icon on the Activity Flex Query panel and give the query a name.
- Under sections, select Statement of Funds. A window opens with the section’s fields. Select all fields, then save the section. If the section offers a choice between a base-currency summary and a breakdown by currency, choose the base-currency summary; that is the view Selfirm reads.
- In the delivery options, set the format to XML and choose a period. IBKR offers fixed periods such as Last Month, Year to Date and Last 365 Calendar Days.
- Click Continue, review, then Create.
Run it
- On the Flex Queries page, click the run icon next to the saved query.
- Save the file to your computer. If several accounts are selected, IBKR offers one combined file or a zip with one file per account.
What the file looks like
The file is XML. The root element is FlexQueryResponse; the cash movements are StatementOfFundsLine elements under FlexStatement/StmtFunds. Each line is one change to the cash balance, and its details are attributes:
| Attribute | What it holds |
|---|---|
accountId |
The IBKR account (a sub-account, such as a futures sub-account, has its own) |
date |
Date as YYYYMMDD, e.g. 20260305 |
currency |
Currency of the line |
amount |
Signed change to cash |
balance |
Cash balance after the change, in the base currency |
activityCode |
Short code for the kind of movement |
assetCategory |
STK for stocks, FUT for futures, and so on |
activityDescription |
Human-readable text |
One balance in the base currency. An IBKR account keeps one cash balance in its base currency, not one per currency like a multi-currency bank account. Holdings (stocks, futures, bonds, options) sit beside that balance.
Balances can be off by a cent. Rounding means a line’s balance can differ from the previous balance plus the amount by 0.01. Selfirm allows that difference and no more.
The same activity code means different things. BUY on a stock is cash turning into a holding. BUY on a future is a daily mark-to-market gain or loss, and the commission is folded into that same cash line. You need both activityCode and assetCategory to know what happened.
The common activity codes and how Selfirm proposes to classify them:
| Code | Meaning | Proposed as |
|---|---|---|
DEP, WITH |
Deposit, withdrawal | Transfer to or from your other accounts |
FOREX |
Currency conversion | Transfer |
BUY, SELL, CORP, EXP on stocks and other securities |
Trades, corporate actions, expiries | Transfer between cash and holdings |
BUY, SELL, ADJ, EXP on futures |
Futures gain or loss, commission included | Investment income (or loss) |
DIV, PIL |
Dividend, payment in lieu of dividend | Investment income |
CINT, INTR |
Interest received | Investment income |
DINT, INTP |
Interest paid, such as margin interest | Investment expense |
OFEE |
Other fees | Investment expense |
FRTAX |
Tax withheld | Investment expense |
Large files. A year of lines for an active account can come to around 190,000 values. Opening it in a spreadsheet works, slowly; checking it by eye does not.
Example
Fictional data, three lines from a Statement of Funds:
<StatementOfFundsLine accountId="U0000000" date="20260305" currency="USD"
activityCode="DEP" assetCategory="" activityDescription="Cash Transfer"
amount="10000" balance="10000" />
<StatementOfFundsLine accountId="U0000000" date="20260306" currency="USD"
activityCode="BUY" assetCategory="STK" activityDescription="Buy 10 EXAMPLE CORP"
amount="-1500" balance="8500" />
<StatementOfFundsLine accountId="U0000000" date="20260320" currency="USD"
activityCode="DIV" assetCategory="STK" activityDescription="EXAMPLE CORP Cash Dividend"
amount="20" balance="8520" />
Read as movements:
| Date | Description | Amount (USD) | Balance | Proposed as |
|---|---|---|---|---|
| 2026-03-05 | DEP · Cash Transfer | 10,000.00 | 10,000.00 | Transfer in |
| 2026-03-06 | BUY · STK · Buy 10 EXAMPLE CORP | -1,500.00 | 8,500.00 | Transfer to holdings |
| 2026-03-20 | DIV · STK · EXAMPLE CORP Cash Dividend | 20.00 | 8,520.00 | Income |
Bringing it into Selfirm
Selfirm is in early access. You upload the XML file as IBKR produced it, along with your bank statements if you like; a whole folder works. Selfirm recognises the Flex Query by its root element and reads the Statement of Funds lines, one account per accountId.
It checks that every balance follows from the one before (within one cent), and that consecutive exports join up. Lines repeated in overlapping exports are counted once. When the bank statement it came from is also in Selfirm, a deposit into IBKR is proposed as a transfer from that bank account, so it is not counted as income. Each movement is classified as income, expense or transfer for you to confirm, and every figure links back to the line of the XML file it came from.
Exporting to CSV or Beancount is planned, not available today. Join the waitlist to try it.
The other US institution Selfirm reads is HSBC Bank USA.
Common questions
Which IBKR report should I export for cash movements?
An Activity Flex Query with the Statement of Funds section, in XML. It lists every change to the cash balance, one line each, with the balance after it.
Is buying a stock an expense?
No. Buying a stock turns cash into a holding; your net worth does not change at the moment of purchase. It is a transfer. Futures are different: the cash rows for futures are daily gains and losses, with commission mixed in.
Why is my Flex Query file so large?
A year of Statement of Funds lines for an active account can run to around 190,000 values. That is fine for a program and impractical to inspect or paste anywhere by hand.
Does Selfirm read the PDF Activity Statement?
No. Selfirm reads the Flex Query XML. The PDF and CSV Activity Statements are not read.