IBKR PnL Aggregator Setup (Flex Queries)

Connect your Interactive Brokers account using IBKR Flex Queries to import and analyze trade history.

  1. Log in to your IBKR Client Portal at interactivebrokers.com.
  2. In the top main menu, click Performance & ReportsFlex Queries.
  3. On the right panel under Flex Web Service Configuration, click the Gear icon ⚙.
  4. On the Configure Flex Web Service page, check Flex Web Service Status and click Save.
  5. IBKR will display your generated Token (a long numeric string, valid for 1 year). Copy this Token.

  1. On the same Flex Queries page, locate the Activity Flex Query card and click the + (Create icon).
  2. Enter a Query Name (e.g. Trade History).
  3. Under Sections, select these recommended items:
    • Trades (executing trades during period)
    • Open Positions (current holdings & unrealized PnL at end of period)
    • Prior Period Positions (starting position holdings at start of period)
    • Change in NAV (starting & ending account values, net asset changes, deposits/withdrawals, dividends)
    • Net Asset Value (NAV) in Base (starting & ending account total NAV)
    • Mark-to-Market Performance Summary in Base (period MTM P&L breakdown)
    • Realized and Unrealized Performance Summary in Base (realized & unrealized P&L breakdown)
  4. Scroll down to Delivery Configuration:
    • Ensure Format is set to XML (default).
    • Set Period to Last 365 Calendar Days (or your preferred range).
  5. Click Continue, review the query setup, and click Create.
  6. On the Complete confirmation screen, click Ok.
  7. Back on the Flex Queries page, locate Trade History under Activity Flex Query and click the blue i (info icon) next to it to view and copy your numeric Query ID.
Privacy Note: Your IBKR Token and Query ID are strictly used client-side to request reports. The Cloudflare Worker only proxies requests to IBKR endpoints to prevent browser CORS restrictions.
Fetch Trade Report
API CONNECTION
LOCAL FILE
Alternatively, select and upload a previously downloaded XML report file directly from your computer.