Interactive Brokers setup guide

Configure an IBKR Activity Flex Query

Compounding Wealth imports Interactive Brokers activity through Flex reports. You need two values from IBKR: a Flex report ID and a Flex token.

Fastest: let your AI agent set it up

On your phone or computer, ChatGPT can do it in its own browser. You sign in to Interactive Brokers there when it asks, and it does the rest.

Set up with ChatGPT

ChatGPT can see the IBKR pages it opens, including the Flex token it generates.

If you use an AI agent that can control your browser, such as Claude or Codex, sign in to Interactive Brokers in that browser and give the agent this prompt:

Set up my Interactive Brokers Flex report for Compounding Wealth by following https://compounding-wealth.com/guides/ibkr-flex-config/agent.md

The agent creates the Flex Query, checks that Flex Web Service is enabled, and helps you generate a token. It gives you the Flex report ID; you copy the token from the IBKR page yourself. Paste both into Compounding Wealth's Add IBKR Flex Report form.

Step 1Create the Activity Flex QueryConfigure the IBKR Activity Flex Query that Compounding Wealth reads.

Target configuration

Create an Activity Flex Query, choose XML, set the period to Last 365 Calendar Days, select all fields in the required sections, and include every account you want to track. Do not share your account numbers or the generated query ID in support messages.

Before you start

  • Log in to Interactive Brokers Account Management.
  • Open Performance & Reports, then Flex Queries.
  • Choose any query name that will help you recognize this report later.

Required sections

Select all fields in every section. For sections that show options, enable the options listed here before selecting all fields.

SectionOptions to enable
CFD ChargesNone
Cash ReportCurrency Breakout
Cash TransactionsAlready ticked when the section opens: every transaction type and Detail. Leave them as they are (see screenshot).
Change in Dividend AccrualsDetail
Commission DetailsNone
Corporate ActionsSummaryDetail
Financial Instrument InformationNone
Forex BalancesSummary
Forex P/L DetailsTransaction
Incoming/Outgoing Trade TransfersTrade Transfers
Interest AccrualsNone
Open Dividend AccrualsNone
Open PositionsSummary
Statement of FundsCurrency BreakoutInclude Starting and Ending Balances
TradesOrderExecution
Transaction FeesSummaryDetailExecution
TransfersTransfer

Delivery configuration

Accounts
Select every account you want to track.
Models
Leave as Optional.
Format
XML
Period
Last 365 Calendar Days

General configuration

Date Format
yyyy-MM-dd
Time Format
HH:mm:ss TimeZone
Date/Time Separator
' ' single space
Profit and Loss
Default
Include Offsetting Trade/Cancel Pairs?
No
Include Currency Rates?
Yes
Include Audit Trail Fields?
No
Display Account Alias in Place of Account ID?
No
Breakout by Day?
No

Step-by-step guide

  1. Open the Flex Queries page

    Confirm the page heading is Flex Queries.

    Interactive Brokers Flex Queries page
  2. Create an Activity Flex Query

    In the Activity Flex Query panel, click the + create button.

    Activity Flex Query create button
  3. Name the query

    Enter any name that will help you recognize the report later.

    Create an Activity Flex Query form
  4. Configure the required sections

    For every section in the table above, open the section, enable the listed options, click Select All for fields, then click the section modal's Save button. After saving, the section tile should appear selected before you move on.

    Cash Report section with Currency Breakout enabled and Select All checked
  5. Select options before selecting all fields

    Some sections have options above the fields table. Set those first, then use Select All. For example, Cash Report uses Currency Breakout.

    Some sections already have the right options ticked when they open. Cash Transactions comes with every transaction type and Detail selected, so only tick Select All and click Save.

    Cash Transactions section with all transaction types and Detail already ticked, and Select All checked
  6. Set delivery and general configuration

    In Delivery Configuration, use Add/Edit Account(s) to select every account you want to track. Set Format to XML  and Period to Last 365 Calendar Days. Then set the general configuration values listed above.

    Delivery Configuration controls showing accounts, models, XML format, and Last 365 Calendar Days
  7. Review the query

    Click the main form Continue button. Confirm the query name, selected sections, delivery settings, and general settings. The final button is labeled Create.

    Bottom of the review page with the Create button
  8. Create the query

    Click Create. IBKR will confirm the custom Flex Query was saved; click Ok to return to the Flex Queries page. When the query appears on the Flex Queries page, copy its Query ID. Compounding Wealth calls this the Flex report ID; keep it with the token you generate in Step 3.

    IBKR confirmation that the Flex Query was saved
Step 2Confirm Flex Web Service is enabledMake sure IBKR allows Flex reports to be fetched by the app.

Return to the Flex Queries page and confirm Flex Web Service Status shows Enabled. Compounding Wealth needs that web service access to read the Flex report.

Flex Web Service Configuration showing status Enabled
Step 3Generate the Flex Web Service tokenCreate the token that Compounding Wealth will use to fetch your Flex Query.
  1. Open Configure Flex Web Service. If Flex Web Service Status is not already checked, check it and click Save.

    IBKR Flex Web Service status checked before saving
  2. In the Generate New Token section, set Expire After to 1 Year, leave Valid for IP Address blank, click Generate New Token, and then click Save.

    IBKR Flex Web Service token form with one year expiry selected

IBKR will show the generated token after saving. Write it down or copy it into your password manager immediately, alongside the Flex report ID from Step 1; you will need both when connecting Compounding Wealth. Do not share either value in support messages.