FeaturesCalculatorsGuidesPricingBrokersLog inStart free trial
Explainer

Creating an Interactive Brokers Flex Query (Lynx too), step by step

In Client Portal (at Lynx: Account Management), go to Performance & Reports › Flex Queries and click + at Activity Flex Query. Pick the sections, choose XML or CSV, and save. Run it with the run arrow. For a tracker, tick only Executions under Trades, select every field, and run it per period of at most 365 days.

Updated 3 December 2026

What is a Flex Query?

A Flex Query is a custom report in IBKR’s Client Portal. You find it under Performance & Reports › Flex Queries. A Flex Query lets you include or exclude information at the field level, where a Customized Activity Statement only lets you include or exclude full sections.1

A Flex Query at Lynx or Mexem

Lynx and Mexem both work through Interactive Brokers. Through Lynx you open an account with Interactive Brokers, and Lynx passes your orders on to IB.2 Mexem describes itself as an introducing broker to Interactive Brokers.3

Lynx calls the portal for your account and reports Account Management, on lynx.nl and lynx.be. It has the Performance & Reports menu.45 Mexem calls its portal Client Portal and offers Flex Queries, exported as text or XML.6 The steps below work in both portals.

For a tracker, don’t use the Transaction History report: Lynx itself says it isn’t suitable for tax purposes.4 Build the Activity Flex Query from the steps that follow.

Creating an Activity Flex Query

Open Performance & Reports › Flex Queries. If you manage several accounts, an account selector opens first: pick your own account. Click the + icon at the top right of Activity Flex Query and enter a name for the query.7

Under Sections, click each section you want. A pop-up opens with all the fields of that section: click each field you want, then click Save.7

Under Delivery Configuration you choose how the report is delivered. The format can be XML, CSV, Text (Pipe) or Text (Tab), and you pick a period.7 Click Continue to review the query, then Create to create it.7 Which sections and fields a tracker needs is in the next section.

Which sections and settings a portfolio tracker needs

IBKR does not say which sections a tracker needs, so this is our instruction. For StockQuarters you pick five sections and select every field in each (see the table).

FXRateToBase is the field that matters most. Without it, foreign-currency lines are skipped and reported, because they cannot be converted to euros.

Under Trades you choose the level of detail. IBKR’s Trades section offers Symbol Summary, Executions, Orders, Asset Class, Closed Lots and Wash Sales.8 For StockQuarters you tick only Executions, not ‘Select All’: otherwise Flex reports the same fill three times, as an execution, an order and a closed lot.

Under Delivery Configuration choose XML (CSV is fine too). Under General Configuration set Date Format to yyyy-MM-dd, and save the query.

The five sections of the Activity Flex Query, for StockQuarters
SectionWhat it holdsWhy a tracker needs it
Account InformationYour account details, including its base currencyWe read your account’s base currency from it, in XML and CSV alike.
TradesYour purchases and sales, one line per fill when only Executions is tickedThese are your transactions.
Cash TransactionsDeposits, withdrawals, dividends and the tax withheldDeposits are cash flows, never profit, and a dividend is kept apart from its withholding tax.
Corporate ActionsCorporate actions on your holdings, such as splitsSo a split is read as a split, not as a purchase or a sale.
TransfersTransfers of shares in or out of the account (ACATS, internal or FOP)So they are booked as shares moving, not as a purchase or a sale.

Running the query, period by period

Go back to Performance & Reports › Flex Queries and click the blue Run arrow to the right of your saved query. Select the period and the format, click Run, and save the file to your computer when asked.9 The file opens in programs that can read text or XML files.9

For StockQuarters, run it per period: IBKR exports at most 365 days per run. The period you save in the query is only its default; you pick the date range when you run it.

Start with your very first trade. Run the query again from the day that period ended, and so on until today. Overlapping by a day is fine, because duplicate lines are skipped. Anything you leave out is missing from your portfolio.

Keep the query. Later you run it again from your previous end date and upload only the new file.

Cash Transactions is on the list for a reason: deposits and withdrawals are cash flows, never profit. Why that matters is in Return with deposits.

Which file StockQuarters reads

StockQuarters reads one Activity Flex Query, as XML or CSV. Lynx and Mexem clients pick Interactive Brokers when they import, then Lynx or Mexem; their account gets that name. You upload the file, never your IBKR password or login.

Several files, one per period or from separate queries? Upload up to 4 files together (at most 4 MB together) and the rest afterwards into the same account; they are added to what is already there.

Transfers of shares and currency conversions are booked as shares or cash moving, never as a purchase or a sale. The detail is on the Interactive Brokers page.

StockQuarters is a paid service after a 7-day trial (see pricing) and stores your data encrypted in the EU.

Sources

  1. According to IBKR’s Client Portal guide, you find Flex Queries under Performance & Reports › Flex Queries. They let you include and exclude information at the field level, where Customized Activity Statements only let you include and exclude full sections. Source: ibkrguides.com/clientportal/performanceandstatements/flex.htm, checked on 2 December 2026
  2. According to Lynx’s own site, you sign a client agreement with LYNX and Interactive Brokers Ireland Limited. LYNX limits itself to receiving and passing on your orders to IB, and with your consent opens an account with IB on your behalf. Source: lynx.nl/online-broker/interactive-brokers-lynx, checked on 3 December 2026
  3. According to Mexem’s own site, MEXEM Ltd acts as an Introducing Broker to Interactive Brokers LLC. Its menu lists Client Portal, and the login goes to clientam.com. Source: mexem.com, checked on 3 December 2026
  4. According to Lynx’s Account Management page, Account Management is an online platform for managing and following up your account. You find the Transaction History report in it under Performance & Reports > Transaction History, and that report is not suitable for tax purposes. Source: lynx.nl/service/software/accountmanagement, checked on 3 December 2026
  5. According to Lynx’s Belgian site (lynx.be), Account Management is an online platform for managing and following up your account, with the Transaction History report under Performance & Reports. Source: lynx.be/service/software/accountmanagement, checked on 3 December 2026
  6. According to Mexem’s Reporting page, you create custom report templates with Flex queries and export the results in text or XML formats. Source: mexem.com/reporting, checked on 3 December 2026
  7. According to IBKR’s Client Portal guide, you create an Activity Flex Query under Performance & Reports › Flex Queries. If you manage several accounts, the Account Selector opens first. You click the + icon in the top right corner of Activity Flex Query and enter a name. Under Sections you click each section you want; a pop-up opens with the fields of that section, you click each field you want and click Save. Under Delivery Configuration you choose the format (XML, CSV, Text (Pipe) or Text (Tab)) and the period. You click Continue to review the query and Create to create it. Source: ibkrguides.com/clientportal/performanceandstatements/activityflex.htm, checked on 2 December 2026
  8. According to IBKR’s Reporting Guide, when you set up the Trades section of an Activity Flex Query you select one or more Levels of Detail for the trade data: Symbol Summary, Executions, Orders, Asset Class, Closed Lots or Wash Sales. Source: ibkrguides.com/reportingreference/reportguide/tradesfq.htm, checked on 2 December 2026
  9. According to IBKR’s Client Portal guide, you run a saved Flex Query under Performance & Reports › Flex Queries by clicking the blue Run arrow icon to the right of it, selecting the period and the format, and clicking Run. When prompted, you save the file to your computer. You can open it in programs that can read text or XML files. Source: ibkrguides.com/clientportal/performanceandstatements/runflex.htm, checked on 2 December 2026

Frequently asked questions

Can I export everything from Interactive Brokers in one run?

No. For StockQuarters you export per period: IBKR exports at most 365 days per run. Start with your very first trade and let each run start where the previous one ended.

Why do my trades appear three times?

Trades probably had more than Executions ticked. With ‘Select All’, Flex reports the same trade as an execution, an order and a closed lot, so every fill appears three times. Tick only Executions and run the query again.

XML or CSV: which should I pick?

Either works. Both carry your account’s base currency as long as Account Information is selected. A CSV holds every section you picked in one file, each with its own header row.

Does this work for Lynx or Mexem?

Yes. Lynx and Mexem both work through Interactive Brokers. At Lynx you build the Activity Flex Query in Account Management, at Mexem in Client Portal, with the same steps. When you import, pick Interactive Brokers and then Lynx or Mexem.

Why must FXRateToBase be selected?

That field carries the line’s exchange rate. Without it a foreign-currency transaction cannot be converted to euros, so those lines are skipped and reported to you separately.

Read your Flex Query file

Upload your Interactive Brokers, Lynx or Mexem Flex Query and see your result, your dividends with withholding tax and your cash flows, with deposits kept apart.

Try it free for 7 days
Data encrypted in EUNo broker connectionCancel anytime