Ploutos Help

Interactive Brokers Flex Import

Set up the IBKR token and Flex Query so Ploutos can import real trade history without touching your broker password.

Use this guide when you want Ploutos to import trade history from Interactive Brokers.

Interactive Brokers Flex is not a live streaming connection. It is a report connection. Ploutos asks Interactive Brokers to generate your Flex report, waits for it to be ready, then imports the XML trade records from that report.

What you need from Interactive Brokers

You need two values:

  • a Flex token
  • a Flex Query ID

Both come from Interactive Brokers Client Portal, not from Ploutos.

Ploutos never needs your Interactive Brokers username or password for Flex import.

Before you create the Ploutos connection

In Interactive Brokers, create or confirm a Flex Query that returns XML trade records.

For historical import, prefer an Activity Flex Query with the Trades section enabled.

Do not rely on a Trade Confirmation Flex Query if Interactive Brokers keeps its period locked to Today. That query can still show your account id, which lets Ploutos discover the account, but it will not backfill past trades if the report window stays on today.

In the General Configuration area, check the Profit and Loss setting. Ploutos needs the report to include realized P&L. If the Trades field picker does not show P&L even after all trade fields are selected, change the Profit and Loss setting to the option that exposes realized P&L for the report.

The query should include:

  • account id
  • symbol
  • buy or sell side
  • quantity
  • trade price
  • commission
  • realized P&L, often shown by IBKR as realized PNL, FIFO realized P&L, or MTM P&L
  • proceeds and cost or cost basis if realized P&L is not available in the field list
  • trade date and time
  • trade id, execution id, or order id

If you trade multiple IBKR accounts, include the accounts you want Ploutos to discover. Ploutos can only show provider accounts that appear in the Flex report.

Create the Flex token

  1. Sign in to Interactive Brokers Client Portal.
  2. Open the reporting area for Flex Queries.
  3. Open Flex Web Service configuration.
  4. Enable Flex Web Service if it is not already enabled.
  5. Copy the current token.

If the token expires or is regenerated later, update the Ploutos connection with the new token.

Create the Flex Query

  1. In Interactive Brokers, create an Activity Flex Query.
  2. Add the Trades section.
  3. Choose XML as the report format.
  4. Include the fields listed above.
  5. Pick a date range that covers the history you want imported.
  6. Save the query.
  7. Copy the Flex Query ID.

For first setup, use a date range that you know contains trades. That makes the connection test much easier to trust.

If you already created a Trade Confirmation Flex Query and the Period field is greyed out on Today, create a new Activity Flex Query instead of continuing with that locked query. Ploutos can import the Trade records from Activity Flex XML.

Connect it in Ploutos

  1. Open the Ploutos account where the IBKR trades should live.
  2. Open Manage Connections.
  3. Choose Add connection.
  4. Select Interactive Brokers Flex.
  5. Give the connection a name you will recognize later.
  6. Paste the Flex token.
  7. Paste the Flex Query ID.
  8. Choose Test connection.
  9. Save the connection after the test passes.
  10. Review the discovered provider accounts and leave only the accounts you want enabled.

After saving, run sync from the connection card. Background sync runs on a slower cadence than Rithmic or Tradovate because Interactive Brokers Flex reports are generated on request.

If no provider accounts appear

Check the Flex Query in Interactive Brokers.

Usually one of these is true:

  • the query does not include account id
  • the date range has no trades
  • the query is pointed at the wrong IBKR account
  • the query returns a report section that does not include trade records
  • the query is a Trade Confirmation report locked to Today
  • the token belongs to a different IBKR user than the query

Update the query, save it in Interactive Brokers, then refresh the connection accounts in Ploutos.

If the connection test fails

Start with these checks:

  • confirm the token is current
  • confirm the Query ID is copied exactly
  • confirm the query output is XML
  • wait a short moment and test again, because Interactive Brokers may still be preparing the report
  • confirm the query includes trades for the selected date range

If the report is empty but the connection succeeds, widen the Flex Query date range or choose a period where you know trades exist.

What Ploutos imports

Ploutos imports execution-level trade records from the Flex report and groups them into trades in the journal when enough fill detail is available.

Keep the Flex Query focused on real trade records. Cash movements, transfers, dividends, interest, and account summaries are useful in Interactive Brokers, but they do not help Ploutos build a trade journal.

Official Interactive Brokers reference

Interactive Brokers documents the Flex Web Service flow as:

  1. send a request with your token and Query ID
  2. receive a reference code
  3. use the reference code to retrieve the generated statement

Reference: Interactive Brokers Flex Web Service.

Next pages