A broker statement looks like it answers "what do I own, and what did it cost me?" It doesn't. It is a lossy, broker-specific view of a ledger you never get to see. Dividends and the tax withheld on them sit in different sections. Splits appear as free-text descriptions. Cash lines settle on different dates from the trades that caused them. The same trade can appear in two overlapping exports, with the price rounded differently in each.
For the past few months I have been building an engine that takes these files (PDF, CSV, XLSX, even screenshots) and rebuilds holdings, cost basis under different tax systems, dividends net of withholding, and performance across accounts in different currencies. It is written in Go. It currently reads 15 brokers through 21 deterministic converters and has about 1,450 test functions. This article follows the data from upload to performance number, along with the bugs that forced most of the design.
If you take away one thing, make it this: an unknown number is not zero.…