Skip to content

How to import an Interactive Brokers portfolio into MEDGE

Five minutes the first time, a click afterwards. You create one report in IBKR Client Portal, turn on the Flex Web Service, and paste two values into MEDGE. Here are the exact settings, what to check after the import and how updates work.

Before you start

You need access to IBKR Client Portal with the username that will own the report, and a MEDGE account (the Free plan is enough).

For advisor and linked account structures, IBKR shows the Flex Web Service token only from the master account, and a Flex Query only covers the accounts selected when it was created.

The four steps

  1. 1Create the report in Client PortalOpen Performance & Reports (or Reporting) › Flex Queries and create an Activity Flex Query with the Open Positions section, at Summary level, in XML format, for the last business day. Save it and note its Query ID.
  2. 2Turn on the Flex Web ServiceIn Flex Web Service Configuration, enable the service and generate a token. Choose the longest validity (up to one year) and leave the IP restriction empty.
  3. 3Paste token and Query ID in MEDGEOn the Portfolio page, under Import from your broker, choose Connect Interactive Brokers and paste the two values. MEDGE downloads the report straight away to check it.
  4. 4Check the positions, then analyseFix any ticker MEDGE did not recognise, untick what you want to leave out, and open the analysis or save the portfolio.

Check your Flex Query before connecting

In Client Portal, run your Flex Query once (the arrow next to it), choose XML and download the file. Drop it here to see whether it has everything MEDGE needs and exactly what it would import.

Drop the XML file here, or

The file is read in your browser and never uploaded.

Step 1: the Flex Query settings

In Client Portal open Performance & Reports (in some versions, Reporting) › Flex Queries, and create a new Activity Flex Query with these settings:

SettingValue
Query nameAny, for example “MEDGE positions”
SectionOpen Positions, with Options set to Summary
FieldsAsset Class, Symbol, Description, ISIN, Listing Exchange, Currency, FX Rate To Base, Quantity, Position Value
FormatXML
PeriodLast Business Day
Date formatyyyyMMdd (the default)

Save the query. Its Query ID is the number shown next to it in the list of Flex Queries. Other sections in the same query are ignored, so you can reuse a query you already have if it includes Open Positions with these fields.

Step 2: the Flex Web Service token

On the same page open Flex Web Service Configuration, tick Flex Web Service Status and save: IBKR shows a Current Token. You can also generate a new token, choosing how long it stays valid (from 6 hours to 1 year, according to IBKR) and, optionally, which IP addresses may use it.

Choose the longest validity, so you do not have to reconnect often, and leave the IP restriction empty: MEDGE’s servers do not have a fixed address, and a restricted token is refused with code 1013.

Step 3: connect in MEDGE

Sign in to MEDGE and open Portfolio. In the Import from your broker panel choose Connect Interactive Brokers, paste the token and the Query ID, and press Connect.

MEDGE asks IBKR to generate the report and downloads it. IBKR prepares it on request, so this takes from a few seconds to about half a minute. If something is wrong, the message names the IBKR error code and how to fix it.

Step 4: check the positions

MEDGE lists the positions with the ticker it will use, the value in the account’s base currency and the weight. Before analysing, look at three things.

Tickers
US listings keep their symbol; other exchanges get the suffix in the table below. A position whose exchange MEDGE does not recognise has an empty ticker box: type it (for example VWCE.DE) or untick it.
What was left out
Options, futures, bonds, currency balances and short positions are listed under Not imported, with the reason. They stay out of the weights.
Weights
They are based on value converted to the base currency with IBKR’s FX rate, so a position in dollars and one in euros are compared fairly. Untick a position to remove it; the others are re-weighted to 100%.

How IBKR exchanges become MEDGE tickers

MEDGE reads the Listing Exchange of each position and adds the suffix its price data uses. A position on an exchange not in this list keeps an empty ticker for you to fill in.

Listing Exchange in the reportExchangeTicker in MEDGE
NASDAQ, NYSE, ARCA, BATS…US exchangesVOO, AAPL
IBISXetraSYMBOL.DE
IBIS2Xetra (ETF)SYMBOL.DE
XETRAXetraSYMBOL.DE
GETTEXgettexSYMBOL.DE
TGATETradegateSYMBOL.DE
BVMEBorsa ItalianaSYMBOL.MI
BVME.ETFBorsa Italiana (ETF)SYMBOL.MI
EUIBSIBorsa Italiana (EuroTLX)SYMBOL.MI
AEBEuronext AmsterdamSYMBOL.AS
SBFEuronext ParisSYMBOL.PA
ENEXTEuronextSYMBOL.PA
EBREuronext BrusselsSYMBOL.BR
LSELondon Stock ExchangeSYMBOL.L
LSEETFLondon Stock Exchange (ETF)SYMBOL.L
LSEIOB1London (IOB)SYMBOL.L
EBSSIX Swiss ExchangeSYMBOL.SW
SWXSIX Swiss ExchangeSYMBOL.SW
VIRTXSIX (VIRT-X)SYMBOL.SW
BMBolsa de MadridSYMBOL.MC
VSEWiener BörseSYMBOL.VI
SFBNasdaq StockholmSYMBOL.ST
CPHNasdaq CopenhagenSYMBOL.CO
HEXNasdaq HelsinkiSYMBOL.HE
OSEOslo BørsSYMBOL.OL
TSEToronto Stock ExchangeSYMBOL.TO
VENTURETSX VentureSYMBOL.V
SEHKHong KongSYMBOL.HK
TSEJTokyoSYMBOL.T
ASXASX (Australia)SYMBOL.AX

What the import includes

ImportedNot imported
InstrumentsStocks and ETFs held long, on any exchangeOptions, futures, bonds, currency balances and short positions: listed as not imported
Data per positionSymbol, description, ISIN, listing exchange, currency, quantity, valueCost basis, lots, realised P&L
WeightsValue of each position converted to the account’s base currency with the FX rate in the reportCash, which does not enter the weights
TimeA snapshot of the open positions on the report date (the last business day)Transactions, dividends, deposits and the account’s past performance
UpdatesOn request, with the Refresh button (at most once a minute per account)Automatic background syncing

After the import

Analyze
Opens the portfolio analyzer with the imported weights already filled in. The link carries the 40 largest positions; each plan analyses up to 10 (Free), 25 (Essential), 40 (Plus) or 60 (Pro) holdings at a time.
Save as portfolio
Keeps the tickers and weights in your account, within your plan’s number of saved portfolios (one on Free).
Refresh
Reads the report again from IBKR. IBKR allows 10 requests a minute per token and one import uses several, so MEDGE allows one refresh a minute per account.
Token expiry
When the token expires IBKR answers with code 1012. Generate a new token in Client Portal and connect again with it: the connection with the same Query ID is replaced.
Disconnect
The bin icon deletes the token from MEDGE. Portfolios you saved are not affected.

Seeing an error message? Here is what each code means.

Questions

Which Flex Query fields does MEDGE need?

From the Open Positions section, at Summary level: Asset Class, Symbol, Description, ISIN, Listing Exchange, Currency, FX Rate To Base, Quantity and Position Value, in XML format for the last business day.

Can I import from a CSV or an Activity Statement?

Not at the moment. MEDGE reads the Flex Query through the Flex Web Service, which gives the listing exchange and the FX rate needed to build the weights correctly. You can still type tickers and weights by hand in the analyzer.

How long is the token valid?

You choose when generating it: IBKR allows from 6 hours to 1 year. Choose the longest, and generate a new one when it expires.

Why does MEDGE ask me not to restrict the token by IP?

Because MEDGE’s servers do not have a fixed IP address. A token limited to some addresses is refused by IBKR with code 1013, IP restriction.

Are my transactions or dividends imported?

No. The import is a snapshot of the open positions on the report date. It does not include transactions, dividends, deposits or the performance your account achieved.

Can I import more than one IBKR account?

Yes, as separate connections, each with its own Query ID: up to 10 broker connections per MEDGE account. A Flex Query covers the accounts selected when it was created.

Related

MEDGE Capital is not affiliated with Interactive Brokers. Interactive Brokers, IBKR, Client Portal and PortfolioAnalyst are trademarks of their owners. Educational content: not financial advice and not an investment recommendation. Risk disclaimer.