Skip to the content

Guides

Connect Interactive Brokers to The Book with a read-only Flex token

Updated About 4 min to read

Steps checked with Interactive Brokers' own guide on

The Book reads your Interactive Brokers accounts with a read-only Flex token you create in your own Interactive Brokers account, plus the Query ID of an Activity Flex Query. It takes about five minutes on Interactive Brokers' website, then one paste into The Book.

On this page · 5 sections

What a Flex token can and can't do

Interactive Brokers makes the report. The Query ID says which report, and the token lets The Book fetch it. A Flex token can only download your reports. It can't place orders or move money.

What comes in: the positions, cash and margin of every account you have at Interactive Brokers, under the names Interactive Brokers gives them, with your trades, deposits, fees and other activity in each stock's history. Options, short sales and shares on a market The Book can't price yet are left out, and the sync says which.

The token and the Query ID are checked with Interactive Brokers, then stored locked to you and never shown again. Security says what else The Book reads, keeps and never asks for.

Step by step

First, on Interactive Brokers' website. The Book's own form shows these same steps:

  1. Sign in at interactivebrokers.com → Performance & Reports → Flex Queries.

    Interactive Brokers also lists it under Menu › Reporting › Flex Queries.

  2. Activity Flex Query → + (create). Name it “The Book”. Tick these sections, each with Select All:
    • Account Information
    • Open Positions
    • Cash Report
    • Trades
    • Cash Transactions
    • Corporate Actions

    Format XML, period Last 365 Calendar Days. Save, and copy its Query ID (a number).

  3. On the same page, Flex Web Service Configuration (the gear) → turn it on → Generate a new token, with the longest expiry. Copy the token.
  4. Paste both in The Book. The token can only fetch reports: it cannot trade or move money.

Then, in The Book:

  1. Open Portfolio › Holdings › Accounts › Add account, name the account, give Interactive Brokers as its broker, and press Next: holdings. Step 2 opens on Connect Interactive Brokers. If you'd rather, press Connect IBKR on the Interactive Brokers card in Settings › Accounts › Connections.
  2. Paste the token into Flex token and the number into Query ID.
  3. Press Connect. The Book asks Interactive Brokers for the report, which takes up to half a minute.
  4. Read what came in: the accounts and holdings Interactive Brokers sent. If it's still making the report, the account card says “Waiting for Interactive Brokers · checks again in 2 min”, and you can leave.

Rather not connect? Interactive Brokers' XML file works as an upload instead: see bringing holdings in from a file.

Today's trades, optional

IBKR's main report updates once a day. A second, small report brings today's trades, about 5 to 15 minutes after each trade. Your token stays the same.

While you connect: on Interactive Brokers' website, open Trade Confirmation Flex Query → + → tick Trade Confirmations (Select All), XML, save, and paste its Query ID into Today's trades Query ID (optional), the third box.

Later: on the Interactive Brokers card in Settings › Accounts › Connections, press Add today's trades, then:

  1. In IBKR: Performance & Reports → Flex Queries → Trade Confirmation Flex Query → + (create).
  2. Name it “The Book today”, tick Trade Confirmations (Select All), format XML. Save, and copy its Query ID.
  3. Paste it into Today's trades Query ID and press Add. Your token stays the same.

The card then says “Today's trades: on”, with Turn off beside it.

If it doesn't connect

The Book shows what Interactive Brokers answered, in plain words, on the form itself. If a later sync fails, the account card says the same with Fix ›, which opens the form again, filled in. The answers you're most likely to see:

  • “No open positions in this query”: the Flex Query has no Open Positions section. Edit the query at Interactive Brokers, tick Open Positions (Select All), save, and try again. Nothing was saved.
  • “Token expired”: the token has run out. In Flex Web Service Configuration, generate a new one with the longest expiry and paste it in.
  • “Query ID not found”: copy the number shown beside the Activity Flex Query, not its name.
  • “Token locked to another address”: the token works only from certain internet addresses. Generate one without an address limit.
  • “Old-style Flex Query”: make an Activity Flex Query, as in step 2, and use its Query ID.
  • “Waiting for Interactive Brokers”: Interactive Brokers accepted the token and is still making the report. It's checked again by itself. If there's still no report after 30 minutes, the card says “Interactive Brokers has not sent the report”; its reports are sometimes slow around the close, so try again later.

Disconnecting

In The Book: on the Interactive Brokers card in Settings › Accounts › Connections, press Disconnect. Your accounts and holdings stay as they are, and no longer update. To remove an account as well, choose Remove account… from its card's ⋯ menu on Portfolio.

At Interactive Brokers: in Flex Web Service Configuration, turn the service off, or generate a new token. Interactive Brokers' own documentation says a new token stops the old one working.

Broker sync comes with both plans, Overdrive and Powered: see Pricing.

Brokers are named only to say what The Book can read. None of them endorses The Book.

This guide is general information about how The Book works. It isn't investment, financial or other professional advice, and it doesn't take your situation into account. The Book is a read-only portfolio tracker: it can't place trades or move money, and nothing here is a recommendation to buy, sell or hold anything. Check any figure that matters with your broker. More in Important notices.

Back to the top ↑

Open your book

New accounts start with two weeks of Overdrive free, and no card is needed. Nothing is charged unless you choose a plan. Without one, the account is paused when the two weeks end and deleted 60 days later.

Create your account

Already have an account? Sign in