Step by step
1. In IB: make the Flex Query
Once only. Each picture shows what to click, boxed in red with its step number. Make a new query even if you already have others in IB: a new one changes nothing else, and changing a query another app uses could break that app.
1. Sign in to IB. In the top menu, open Performance & Reports, then click Flex Queries.
2. Beside Activity Flex Query (not Trade Confirmation Flex Query), click + to make a new query.
3. In Query Name, type Kodahfy.
4. Under Sections, click the first section. In the box that opens, tick Select All at the top, then click Save at the bottom. The section turns blue with a tick. Do the same for every section in the list; Kodahfy takes what it needs and ignores the rest.
5. At the bottom of the page, set these three, leave everything else as it is, and click Continue to save the query:
- Format: XML. If it says CSV, change it to XML: Kodahfy reads XML only.
- Period: Last 365 Calendar Days.
- Include Currency Rates?: Yes.
Rather upload a file than connect? The same query works as a file (steps 6 to 8). It goes down exactly the same path as the nightly pull.
Uploaded an Activity Statement or a Transaction History and it was refused? Those are IB's other reports, and Kodahfy does not read them: they cannot say whether a trade opens or closes, nor when an option expires. Make the Kodahfy query (steps 1 to 5), then run it and upload its file (steps 6 to 8), or connect it (part 2 and 3 below).
6. Each time you want a file: in the Activity Flex Query list, click the run arrow beside Kodahfy, then click Run.
7. Wait until it appears under Batch Flex Queries on the right, then click its download arrow.
8. In Kodahfy, open Transactions → Import Data and upload that file.
2. In IB: the Query ID and the token
1. Find the Query ID: in the Activity Flex Query list, click the ⓘ beside Kodahfy and copy the number shown as Query ID.
2. On the same Flex Queries page, on the right, click the gear beside Flex Web Service Configuration.
3. The token. IB allows one Flex Web Service token at a time, and a new one stops the old one everywhere it is used. If you already have your token (another app uses it), use that same one. If you don't have it, generate a new one there and copy it; any other app that used the old token then needs the new one too. A token carries an expiry you choose, up to a year: an expired token is the most common reason a working sync stops later.
3. In Kodahfy: connect
1. Open Settings → Accounts. Under Broker Integrations, on the Interactive Brokers line, click Connect.
2. Paste the token into Flex Token and the number into Query ID. Under Sync To Account, choose your Interactive Brokers account, or leave Create new account and Kodahfy makes one called Interactive Brokers.
3. Click Connect. Kodahfy checks the token and Query ID with IB, saves them, and starts bringing your year in. Nothing else to press.
4. Your year comes in by itself
Straight after Connect, a line at the top of the page says Bringing in your year from Interactive Brokers…. It often takes about a minute, longer for a busy year. You can go to any other page: the line stays at the top wherever you are. When it is done, the It's in screen opens by itself if you are still in Kodahfy; if you have gone, the line at the top says Interactive Brokers is in (or why it stopped) the next time you sign in, with See it to open the screen. It stays until you have seen it:
- If Kodahfy files your trades for you (Auto-Match on, as it is for a new login), it shows the trades it made and their profit. Nothing else to do.
- If not, it asks the one question: how should we file them? Pick Kodahfy, all into one system and it turns them into trades now, or I'll do it myself, in Reconciliation and they wait there for you. It is asked once, for this account; change it any time on the same screen or in Settings, Automation.
If IB refuses (a Query ID it does not know, a query set to CSV, a token that has expired), the page says what is wrong in one line and what to do. If your Flex Query leaves things out (a section not ticked, a period shorter than a year on the first sync, no currency rates), what did come in is kept, and the page says in one line what to change in the query; Needs you keeps saying it until a sync comes back whole.
The chip on the Interactive Brokers line in Settings → Accounts says how the last pull went: Connected when it was fine, Last sync failed (red) or Only part came in (amber) when not, with the reason and what to do written under the line.
From then on the nightly pull is on: new trades and cash arrive every night without you doing anything. Settings → Automation shows it in the account's 1 · Comes in cell (Every night), with Sync now for a pull straight away and the switch to turn the nightly pull off. The round arrow on the Interactive Brokers line in Settings → Accounts is the same Sync now: it shows Pulling…, then what came in (or Nothing new from Interactive Brokers since the last pull). A pull that takes longer carries on by itself, and how it ended shows at the top of whatever page you are on. The next cell, 2 · Turned into trades, says who turns this account's buys and sells into trades; press Change there to alter it.
Connected with the wrong query
If you connected an existing query (one set to CSV, or another app's), you don't need to start again. Make the Kodahfy query (steps 1 to 5 above) and copy its Query ID. Then in Settings → Accounts, click the pencil on the Interactive Brokers line (Edit IB Credentials), replace the Query ID, leave Flex Token empty to keep the token you have, and click Save. Then click the round arrow on the same line (Sync now).
When the sync stops working
The line on the screen says what is wrong and what to do. Most often the token expired: in IB, click the gear beside Flex Web Service Configuration and generate a new one (it stops the old one in any other app that uses it). Then in Settings → Accounts, click the pencil on the Interactive Brokers line (Edit IB Credentials), paste the new token into Flex Token and click Save. When the nightly pull keeps failing, Kodahfy raises it on the Needs you page, so you'll know before your data drifts.