Application

Getting Started

This guide walks you through connecting your Interactive Brokers account so Optionslab can load your positions, track your trades, and compute statistics over your closed trades.

By the end you will have:

  • Flex Web Service enabled and a token saved
  • An Open Positions Flex Query and its query id saved
  • Optional: a Trade Confirmations Flex Query for intraday and same-day positions
  • Optional: a Historical Trades Flex Query to unlock the Stats page
  • Your IBKR account connected in Optionslab with positions syncing automatically
Why Flex Queries?Flex Queries are IBKR’s canonical way to let third-party tools read your account data. They are free, work for retail accounts, and expose both current positions and historical trades without needing the TWS desktop app to be running. Flex Web Service docs

Step 1 — Enable Flex Web Service

Log in to Client Portal and open Performance & Reports → Flex Queries.

Flex Queries section in Performance & Reports

Scroll to Flex Web Service Configuration at the bottom of the page. This is the switch that lets Optionslab fetch your reports over HTTPS.

Flex Web Service Configuration section

Enable the service and generate a token. IBKR will display it once — copy it somewhere safe; you will paste it into Optionslab in the last step.

Generated Flex Web Service token
The token is a bearer credential: anyone holding it can read the reports you define. Optionslab stores it encrypted (AES-256) and never exposes it back to the UI. You can rotate it at any time from the same screen and re-enter the new token in Optionslab.

Step 2 — Open Positions Report (required)

This is the primary report. It is a daily end-of-day snapshot of every lot you currently hold — stocks, options, futures. Optionslab uses it to build the Positions page.

In the Activity Flex Query block, click the small plus (+) icon to create a new query.

Plus icon to create new Activity Flex Query

Give it a recognisable name, e.g. Optionslab Open Positions.

Name field for new query

In the Sections block, click Open Positions to open its field selector.

Sections block with Open Positions

In the Options dropdown pick Lot, then tick Select all to include every field. Click Save at the bottom of the dialog.

Why “Lot” level? IBKR can emit positions at summary, lot, or closed-lot granularity. Optionslab needs lot-level rows so it can track per-opening-date cost basis, partial fills, and rolls correctly. Summary rows would collapse these into aggregates and break PnL attribution.
Open Positions field selector with Lot option and Select all

Leave the Delivery Configuration section on defaults.

Delivery Configuration defaults

Leave the General Configuration section on defaults too.

General Configuration defaults

Click Continue, then Create. You will land back on the query list — click the small pencil icon of your new report to re-open it.

Pencil edit icon next to the report

At the top you will see a numeric Query ID. Copy it — you will need it together with the token in the final step.

Query ID at the top of the report

Step 3 — Trade Confirmations Report (optional)

The Open Positions report is refreshed by IBKR once per day, after the market close. That means positions you open or close today will not appear until tomorrow.

Trade Confirmations solve this. IBKR updates them every few minutes during the trading day, so Optionslab can merge them with the daily snapshot and show an up-to-date view — including same-day scalps, 0DTE trades, and rolls.

Skip this if you only trade multi-day positions and do not care about intraday accuracy.

In the Trade Confirmation Flex Query block, click the plus (+) icon.

Plus icon in Trade Confirmation Flex Query block

Name it and open the single Trade Confirmation section.

Trade Confirmation section

In Options pick Execution, tick Select all, and click Save.

Execution option with Select all

Save the query, then re-open it via the pencil icon and copy its Query ID.

Step 4 — Historical Trades Report (optional)

The Stats page needs your closed trades to compute win rate, PnL distribution, drawdown, and edge analytics. This query exports exactly that.

Skip this if you do not plan to use the Stats page. You can always add it later — no re-configuration is needed on the Optionslab side beyond pasting the new query id.

Back in the Activity Flex Query block click the plus (+) icon again.

Plus icon to create new Activity Flex Query

Give it a name, e.g. Optionslab Historical Trades.

Name field for historical trades query

In the Sections block, click Trades.

Trades section in Sections block

In Options pick Closed Lots, tick Select all, and Save.

Closed Lots option with Select all

In Delivery Configuration change Period to Year to Date (or a longer window if your broker supports it). Leave everything else on defaults.

Delivery Configuration with Period set to Year to Date

Leave the General Configuration section on defaults.

General Configuration defaults

Save, re-open the query via the pencil icon, and copy its Query ID.

Reference: IBKR — Create an Activity Flex Query

Step 5 — Connect your account in Optionslab

With the token and one or more query ids in hand, open the Accounts page and click Add IBKR Portfolio.

Add IBKR Portfolio button on Accounts page

Paste the token and the query ids into the matching fields in the dialog.

Add IBKR Portfolio dialog

Choose an Import Mode. Options only or Options plus underlyingsare the easiest starting points — they filter out unrelated stock holdings you do not want tracked here.

Click Add portfolio. Optionslab will save the config and start a background sync. Press the refresh icon on the right side of the row if you want to trigger an immediate pull.

IBKR generates a fresh report each time it is requested and caches it for a short while. The very first pull can take up to a minute — subsequent syncs are fast. After the first successful sync, Optionslab will refresh your data once per day automatically.

Where to go next

Now that your account is connected, here are the pages you will likely use most:

Positions
See every open lot grouped by underlying, with live prices, unrealised PnL, and expiration.
Go to Positions
Stats
Win rate, PnL distribution, drawdown, and edge analytics computed from your closed trades.
Go to Stats
Playground
Build multi-leg option positions, drag strikes and price, and see the payoff in real time.
Go to Playground
Wizard
Guided strategy selection — answer a few questions and get a fitting options structure.
Go to Wizard
Calendars
Subscribe to market holidays, earnings, and your portfolio’s expiries in your own calendar app.
Go to Calendars
Accounts
Manage connected IBKR portfolios, rotate tokens, and trigger manual refreshes.
Go to Accounts
Manual Import
Prefer not to store a token? Drop an Open Positions Flex Report XML file here instead.
Go to Import