← All guides
Interactive Brokers
Automatic import through the Flex Web Service
With the automatic import, Taxify downloads the statement from Interactive Brokers (IBKR) itself. You set it up one time: the Flex Query, the token and the connection in Taxify. Then you load the trades, the dividends and the corporate actions with one button.
The automatic import is part of the paid plans. On the free plan, use the manual import. See the plans
What the automatic import does
- The "Sync now" button loads the new trades, dividends and corporate actions since the last sync. You do not download or upload a file.
- You load the earlier years in one step: IBKR gives the data of the current year and of the four years before it.
- After each sync, you see what was added: the new trades, the trades that Taxify already had, and the trades that you deleted.
- You can use the manual and the automatic import together. Taxify finds a trade that it already has and does not save it again.
1Prepare the Flex Query
- 1.The automatic import uses the same Activity Flex Query as the manual import. If you have one already, use it.
- 2.If you do not have one, create it with steps 1 to 3 of the manual import guide: the sections and the settings are the same. The format must be XML.
- 3.You do not need to change the Period of the query. For each sync, Taxify sets the days of the statement itself.
- 4.Find the Query ID. It is the number of the query that IBKR shows next to its name in the Flex Queries list. If you do not see it there, open the details of the query (the i icon).
Open the manual import guide (the sections and the settings of the Flex Query)
In the Trades section, set levelOfDetail to EXECUTION. Taxify matches the trades by their IDs. With another level of detail, the trades can have other IDs than in the files that you uploaded before, and duplicates occur.
2Generate a Flex Web Service token
- 1.In the IBKR Client Portal, open Performance & Reports → Flex Queries.
- 2.Find the Flex Web Service Configuration part and open its settings.
- 3.Enable Flex Web Service Status and save the settings.
- 4.Click Generate A New Token. Set the validity and the IP address as the table below shows, and generate the token.
- 5.Copy the token. Also write down the date until which it is valid: Taxify shows the date and warns you before the token expires.
When you generate the token, set:
- Flex Web Service Status
- enabled
- Should Expire After
- the longest validity in the list (the default is only 6 hours)
- Valid For IP Address
- empty – no IP address restriction
A new token cancels the old one. If another app uses the token, that app stops working when you generate a new token – and the other way round: if you generate a token for another app, the sync in Taxify stops. Then save the new token in Taxify; it also replaces the old token on your other accounts that used it.
Leave the IP address field empty. Taxify connects to IBKR from cloud servers whose IP address changes. IBKR refuses a token that is limited to one IP address.
3Connect IBKR in Taxify
- 1.In Taxify, open Accounts and select your Interactive Brokers account. If you do not have one yet, create it.
- 2.Go to the Settings tab, to the IBKR sync part.
- 3.Enter the Flex Query ID, the token and the date until which the token is valid.
- 4.Click "Connect and test". Taxify asks IBKR for the statement of the last 7 days and saves nothing.
- 5.Check the result of the test: the access, the account number, the level of detail and the Transfers section. If the Flex Query holds several IBKR accounts, select the one that the Taxify account belongs to.
4Load the history
- 1.After a good test, Taxify offers the years that it can load. The years that you have not uploaded yet are selected.
- 2.Keep the earlier years selected. With the FIFO method, a sale is matched with the oldest purchase, which can be several years old.
- 3.Click "Load the selected years". Taxify loads one year after the other; the Import tab shows the progress.
Through the Flex Web Service, IBKR gives only the current year and the four years before it. Upload the earlier years as files. Manual import guide
5Sync
- 1.On the Import tab, click "Sync now".
- 2.Taxify loads the days since the last sync. The page shows the progress and the result at once.
- 3.The result shows the new trades and dividends, the trades that Taxify already had, and the warnings, if any. The sync history is below the result.
Security: the token only reads
The Flex Web Service token is not your password. IBKR issues it only to read statements (Flex Queries). Nobody can trade or move money with it.
What the token allows
- Read the Flex Query statements of your IBKR login, with the data of the sections that you enable in the query: trades, dividends and withholding tax, corporate actions, positions.
- Taxify runs only the query whose Query ID you enter, and only for the period that it needs.
- It is the same data that you would otherwise download as an XML file and upload by hand.
What the token does not allow
- Place or cancel orders, that is, trade.
- Withdraw or send money, or move positions.
- Change the account settings or the personal data.
- Log in to the Client Portal or to a trading platform.
How Taxify protects the token
- Taxify stores the token encrypted (AES-256). The decryption key is kept apart from the database, so the database alone does not reveal the token.
- The token never goes back to the browser. In the app, you see only its last four characters. The Taxify support cannot see it either.
- The token is not in the logs or in the error reports. The server uses it only for the encrypted connection (HTTPS) to IBKR.
How to stop the access
- In Taxify: on the Settings tab, click "Disconnect the sync". Taxify deletes the token at once. The loaded trades stay.
- In IBKR: generate a new token (the old one stops at once) or disable the Flex Web Service.
- When you delete your Taxify account, Taxify also deletes the token.
The validity of the token
- IBKR issues the token for the period that you select. The default is only 6 hours, so select the longest option in the list.
- Taxify shows the date when the token expires. 14 days before that date, it warns you on the account page and on the account card.
- When the token expires, the sync stops. The loaded trades stay. Generate a new token in IBKR and save it in Taxify; the Query ID does not change.
How the sync works
- Each sync starts 7 days before the end of the one before it. Thus Taxify also catches the trades that IBKR corrects later.
- A trade that Taxify already has is skipped. This is also true for the trades of the files that you uploaded by hand.
- A trade that you deleted in Taxify stays deleted. The sync does not overwrite a trade that you edited.
- If IBKR cancels or corrects a trade later, Taxify warns you and lists the trades. It does not delete anything – you decide.
- If new trades belong to a year with a locked tax report, Taxify warns you. The locked report does not change.
- The IBKR statement holds the data of closed trading days. The trades of today can appear only in the sync of the next day.
- IBKR usually prepares the statement in a few seconds, and longer for a full year. Keep the page open; if you close it, Taxify continues on your next visit to the account.
If something does not work
- The token expired
- Generate a new token with the longest validity in IBKR, and save it in Taxify on the Settings tab.
- IBKR did not accept the token
- Probably you generated a new token since, which cancelled the old one, or you did not copy all of the token. Save a valid token in Taxify.
- The token is limited to an IP address
- Generate a new token and leave the Valid For IP Address field empty.
- IBKR does not know a Flex Query with this ID
- Check the Query ID. The query must be an Activity Flex Query in XML format, saved in your login.
- The Flex Web Service is off
- In Flex Web Service Configuration, enable Flex Web Service Status.
- The Flex Query holds several IBKR accounts
- In the connection test, select the account that the Taxify account belongs to. Or create a separate query for each account.
- The trades do not have the level of detail EXECUTION
- In the Trades section of the Flex Query, set levelOfDetail to EXECUTION, and test the connection again.
- IBKR did not give the statement now
- IBKR is busy for a moment. Try the sync again later.