How to export your broker trade history
The CSV in your broker's account menu is the ground truth. Getting it out is easy; making two brokers agree about what a trade was is the work.
Start at the broker: almost every one exports a CSV of fills, and that file is the ground truth. A journal will import it, and Tradervue and TradesViz both have free tiers that do. For a program rather than a product, SnapTrade and Plaid read the same history over an API. What breaks is not the export but the reconciliation: partial fills, multi-leg options and a lookback window measured in months.
The short way
Every broker has this, under a menu called Statements, Activity, History or Tax Documents: download a CSV of your fills for a date range, and keep it. That file is the primary record. Every tool below either reads it or reads the same thing over an API, and none of them can reconstruct what the broker did not give you.
Do it before you need it. Brokers age out their download windows, and a closed account frequently stops offering the export at all.
Then pick what reads it. TradesViz is free forever with no card at 3,000 executions a month, stocks only; Tradervue has a free Basic plan capped at 30 imported trades a calendar month, which is not advertised on its pricing page — you pick it at signup instead of the trial.
What the options are
A journal that syncs. Tradervue imports fills from 81 brokers and platforms and is the oldest product in the category. TraderSync syncs directly from 76 brokers and takes CSV uploads for the other 415 on its list, and classifies options spreads on import rather than leaving you four unrelated legs. TradesViz treats stocks, stock options, futures, futures options, forex, crypto and CFDs as first-class instruments once you are off the free plan.
An aggregation API. SnapTrade returns account activities — buys, sells, dividends, fees, transfers, splits, option events — in reverse chronological order by trade date, paginated at a maximum of 1,000 transactions per request, with optional start and end dates. Plaid Investments covers over 3,200 US and Canadian institutions and returns tax lots on holdings, with cost basis, purchase price and purchase date per lot.
Tax software. TradeLog is a different purchase from all of the above: it rebuilds a US trader's tax year from raw broker history and prints Form 8949 detail for Schedule D, Form 6781 for Section 1256 contracts, and Section 475 mark-to-market on its higher tiers. Eight of its 35 supported brokers import through an in-app API connection that runs on SnapTrade; everything else is a file you download yourself.
A tracker rather than a journal. If the question is what you hold and what the return was rather than how you traded, portfolio trackers is the neighbouring listing and Sharesight is the one that produces real tax reports for several jurisdictions.
Interactive Brokers: Flex Queries
IBKR has the ordinary statement download, but the route most importers ask for is a Flex Query: a report template you build once in Client Portal, under Performance & Reports, then Flex Queries. IBKR describes them as customisable templates for Activity Statements and Trade Confirmation reports, chosen field by field rather than section by section. An Activity Flex Query is the statement-shaped one — you tick sections such as Trades, then the fields inside each and the order they print in. A Trade Confirmation Flex Query is the execution-shaped one, and some importers ask for it instead; read the journal's own instructions before building either. Options need one more section: expiries and assignments are not trades, and IBKR keeps them in Option Exercises, Assignments and Expirations (recording options trades in a journal has the detail).
The format and the window are set in the template. Format is XML, CSV, or pipe- or tab-delimited text. Period is a menu — last business day, week, month or quarter, last 30 or 365 calendar days, last N days, month, quarter or year to date — and running a saved query from the portal lets you pick it again. IBKR's guide says saved Flex Queries are available for the four previous calendar years and from the start of the current one, which is how far back this route reaches. Within that, one run covers a year at most: IBKR's Flex Web Service page, read on 9 October 2026, caps both the period override and the from-date and to-date override at 365 days, for SendRequest and GetStatement alike. Five years of history is five runs and a merge.
Scheduled delivery is email unless you ask. Any saved query can be ticked for delivery; email is the only method by default, and sFTP and encryption are each available on request from IBKR's client services, by its delivery-settings page dated 3 October 2025.
The Flex Web Service is the API. Enable it under Flex Web Service Configuration and Client
Portal issues a token; a new one can be set to last anywhere from six hours to a year and
restricted to an IP address. A run is two calls. SendRequest takes the token, the query's ID
and v=3, optionally with fd and td for a date range, and returns a reference code;
GetStatement with that code returns the report in the template's format once it has been
generated. IBKR paces it at one request a second and ten a minute per token, and answers anything
faster with error 1018.
import time
import xml.etree.ElementTree as ET
import requests
BASE = "https://ndcdyn.interactivebrokers.com/AccountManagement/FlexWebService"
FLEX_TOKEN = "YOUR_FLEX_TOKEN" # Client Portal > Flex Queries > Flex Web Service Configuration
QUERY_ID = "YOUR_QUERY_ID" # the Info icon beside the saved Activity Flex Query
RETRY = {"1001", "1004", "1009", "1019"} # IBKR's "please try again shortly" codes
def flex_report(fd: str, td: str) -> str:
"""One run of a saved Flex Query for fd..td (YYYYMMDD, at most a year apart)."""
sent = ET.fromstring(requests.get(f"{BASE}/SendRequest", timeout=60, params={
"t": FLEX_TOKEN, "q": QUERY_ID, "v": 3, "fd": fd, "td": td}).text)
if sent.findtext("Status") != "Success":
raise RuntimeError(sent.findtext("ErrorCode"), sent.findtext("ErrorMessage"))
ref = sent.findtext("ReferenceCode")
for _ in range(30):
time.sleep(10) # inside ten requests a minute
body = requests.get(f"{BASE}/GetStatement", timeout=120,
params={"t": FLEX_TOKEN, "q": ref, "v": 3}).text
if not body.lstrip().startswith("<FlexStatementResponse"):
return body # the report itself, XML or CSV as the template says
reply = ET.fromstring(body)
if reply.findtext("ErrorCode") not in RETRY:
raise RuntimeError(reply.findtext("ErrorCode"), reply.findtext("ErrorMessage"))
raise TimeoutError(ref)
trades_2025 = flex_report("20250101", "20251231")
On 9 October 2026 both endpoints answered a made-up token with a FlexStatementResponse whose
status was Fail and whose error code was 1020, which is the shape the function checks for. The
success path needs an account, so look at the first file it returns before trusting the loop. Some
cards here read the same service rather than a file — Sharesight and
TradingDiary Pro pull Interactive Brokers through it — and
Portfolio Performance imports the Flex Query XML file directly.
Where this breaks
The export is not a standard. Every broker's CSV has its own columns, its own date format, its own sign convention and its own idea of what a row is, and any of them can change without notice. This is why an importer's supported-broker list is a real feature rather than marketing: somebody maintains a parser per broker, and a broker not on the list means mapping columns by hand every time.
Partial fills multiply. One order can arrive as a dozen executions. Plan limits are counted in executions and your intuition is counted in trades, and the gap is usually a factor of two or more — TradeLog's own example is that 100 round trips typically come to 200 records or more. Read any "trades per month" cap as executions until the vendor says otherwise.
Multi-leg options arrive as legs. A four-leg spread that imports as four unrelated trades gives you four wrong P&L figures and no record of the position you actually had. This is the single thing to test with a sample file before paying for anything, and it is why TraderSync leads with spread detection.
The API lookback is short. Plaid's investments transactions endpoint is documented as up to 24 months. SnapTrade will go back to the earliest available transaction, but "available" means whatever the brokerage exposes, which is frequently less than your account's life. Anything older than the window lives only in the broker's own archive.
The 1099-B is not your trade history. It is a summary with the broker's own wash-sale adjustments already applied and no statement of which cost basis figures were changed, covering only positions closed in the year. Reconstructing a tax year from it is not possible, which is why the software built for that job starts from raw fills and reconciles gross proceeds against the form rather than importing it.
Two accounts do not reconcile themselves. Transfers in kind, corporate actions and anything moved between brokers arrive as an opening position with no history behind it. Someone has to supply the cost basis, and that someone is you, from the statement of the account it came from.
If you outgrow this
When you are filing rather than reviewing, the tool changes. A journal answers "was that setup any good"; tax software answers "what does Schedule D say", and the two are not substitutable. TradeLog is the US-specific answer here at $219 a year for up to 1,500 records.
When you want it in a program, move from CSV to brokerage account aggregation. One API, one auth flow, and history that refreshes instead of being re-downloaded — at the cost of a per-connection bill and a lookback window.
When several accounts have to agree, the problem is reconciliation rather than import, and a tracker built around multiple brokers and currencies is the right shape: Sharesight, Portseido and Kubera are the cards for that.
When the journal's own export matters, check it before you commit. Getting data into a product is always easier than getting it out again, and Tradervue's free Basic plan, for one, has no CSV export at all.
The rest of the category is trading journal software.
The tools that do this
In the order this page recommends trying them. Paid placement does not affect this order.
Tradervue
81 supported brokers and a free tier that still works — 30 imported trades a month, no CSV export back out.
The category's oldest journal, 81 supported brokers, and a free tier that still works.
$29.95/moFree tier
TradesViz
Free forever at 3,000 executions a month, stocks only. Seven instrument types once you pay.
The analytics-heavy journal: 150+ base charts across seven instrument types.
$19.99/moFree tier
TraderSync
Direct sync from 76 brokers, CSV upload for 415 more, and options spreads classified on import.
Trade journal with options spread detection on Elite and market replay down to 250ms.
$29.95/mo
SnapTrade
The API answer. Paginated activity history with start and end dates, 1,000 transactions per request.
One API for reading brokerage holdings and placing orders at supported brokers.
$100/moFree tier
Plaid Investments
3,200 US and Canadian brokerages, with tax lots on holdings — and a hard 24-month transaction window.
Read-only holdings, cost basis and investment transactions from 3,200 brokerages.
Free tier onlyFree tier
TradeLog
For US taxes rather than for review. Rebuilds Form 8949 and wash sales from raw fills, refusing the 1099-B.
Wash sales and Form 8949 rebuilt from raw broker trade history, not from the 1099-B.
$219/yr
FAQ
Why will a tax tool not just read my 1099-B?
Because a 1099-B is a summary, not a history. TradeLog's stated reasoning is the clearest version — the form has already had the broker's own wash-sale adjustments applied without saying which cost basis figures were changed, and it reports only positions closed in the year, so it cannot support a full-year calculation. It asks for gross proceeds from each 1099-B and reconciles its own total against them instead.
What is the difference between an execution and a trade?
An execution is one fill as the broker reports it; a trade is the round trip you actually took, which may be assembled from many. This matters because plan limits are usually counted in executions. TradeLog's own example is that 100 round trips typically come to 200 records or more, so the tier you need is at least double your round-trip count.
Can I get more than two years of history through an aggregation API?
Not through Plaid, whose investments transactions endpoint is documented as up to 24 months. SnapTrade's activities endpoint takes start and end dates and defaults to the earliest available, but what is available is whatever the brokerage exposes. For anything older than the API window, the broker's own statement archive and its CSV export are the only sources, and they are worth downloading before you need them.
Do I need a journal at all, or will a spreadsheet do?
A spreadsheet is fine for the record and poor at the question. What a journal buys is the reconstruction — matching fills into round trips, attaching the chart at entry and exit, and grouping by setup so the answer to "which of these actually makes money" is one click rather than a pivot table you maintain. If you are not going to ask that question, the spreadsheet is the honest answer.
How far back can I export trades from Interactive Brokers?
Through Flex Queries, IBKR's guide says saved queries are available for the four previous calendar years and from the start of the current one. Each run covers a year at most — IBKR's Flex Web Service page caps both the period override and the from-date and to-date override at 365 days — so a longer history is several runs, one year each, merged.
Sources
- Investments — Plaid Docs — Plaid, read
- Account Information — getAccountActivities — SnapTrade, read
- Flex Queries — Client Portal User Guide — Interactive Brokers, read
- Create an Activity Flex Query — Client Portal User Guide — Interactive Brokers,
- Configure Delivery Settings for Flex Queries — Client Portal User Guide — Interactive Brokers,
- Flex Web Service — Enable and Create Access Token — Interactive Brokers, read
- Trigger report generation (SendRequest) — Web API reference — Interactive Brokers, read
- Flex Web Service — Error Codes — Interactive Brokers, read
- Configure Flex Web Service — Client Portal User Guide — Interactive Brokers, read
The catalogue next door
This page names a handful of cards. The rest of them are in Trading Journal Software, each filled in against the same schema, with the fields to narrow it yourself.
Last updated . Corrected in place: this is a reference page, not a dated post.
Report an error on this page
Anything else — a question this page leaves open, a tool it should be compared with? Write to feedback@stockmarketstack.com.