Zero-Upload Browser Wasm for IBKR Flex XML: Computing 365-Day FBAR Peaks and Cost-Basis Schedules in Client RAM
Cross-border brokerage reconciliation breaks homegrown spreadsheets in three predictable places: IEEE-754 floating-point penny drift across fractional splits, multi-currency daily valuation curves for FBAR/8938 single-day maximums, and the privacy problem of uploading complete account numbers and net-worth ledgers to third-party servers. Here is the local Rust-to-WebAssembly workpaper architecture we built to solve all three with zero network egress.
# Generate anonymized synthetic IBKR Flex XML & verify compiled Wasm locally (0 bytes uploaded)
npm run test:rust # 10/10 pure-Rust i128 fixed-point & §1091 unit tests
npm run build # compiles wasm32-unknown-unknown (~381 KB release binary)
npm test # 8/8 Vitest checks against compiled dist/ibkr_zerotax.wasm
npm run generate-sample -- --year 2025 --account U9001234 > sample.xml
1. Why IEEE-754 Floats & Cloud Uploads Fail Serious Books
- Single-Day FX Peak Accounting: FinCEN Form 114 (
FBAR), IRSForm 8938, and Canada CRAT1135do not stop at Dec 31 closing balances. They inspect the highest single-day FX-adjusted balance across all365/366days, coupled with corporate action splits (FS/RS) and option assignment/exercise basis adjustments. - Binary64 Rounding Drift: Tracking fractional share lots, partial fills, and pro-rata 61-day (
[-30, +30])IRC §1091deferral windows in standard JavaScript `Number` floats accumulates subtle10^-15errors that fail CPA tie-outs by $0.01–$0.04 on large ledgers. - Privacy Boundary: An Interactive Brokers Flex Query XML file (
<FlexStatement>) reveals account IDs, cash balances, margin interest, and every timestamped fill. Most serious accounts refuse to upload that file to an unverified web backend.
2. Deterministic Pure Rust → wasm32-unknown-unknown Pipeline
Core Module (crates/ibkr-wasm/) |
Engineering Guarantee | Verification Scope |
|---|---|---|
fixed.rs (i128 Fixed-Point) |
Exact integer scaling at 10^-8 precision across quantities, FX, and splits |
Zero floating-point drift on fractional fills & pro-rata deferrals |
xml.rs & ibkr_parser.rs |
Zero-dependency Rust parser with DOCTYPE/XXE rejection + CSV/HTML formula XSS neutralization |
Parses Flex Query XML, Activity Statement CSV, and flat CSV fallback |
date.rs & tax_engine.rs |
Proleptic Gregorian calendar, IRS Pub 550 leap-year rules, FIFO/LIFO lot matching & §1091 61-day window |
Verified across 10 Rust unit tests + 8 compiled Wasm Vitest specs |
cross_border.rs & reports.rs |
365/366-day FBAR curve + Form 8949 / CRA T1135 CSV + printable CPA audit sheet |
~381 KB static Wasm binary; DevTools Network tab confirms 0 bytes uploaded |
The accompanying open-source Flex XML schema validator and synthetic statement generator CLI are already published under MIT ahead of the Dec 15 hosted Wasm web release.
Try the free 0-upload Wasm browser demo & MIT CLI today: Run the live browser-local IBKR Flex XML 0-Upload Wasm Sandbox (0 bytes leave RAM) or inspect github.com/luxiaolei/ibkr-flex-xml-toolkit for offline Flex Query XML structure inspection and synthetic test data generation. The full hosted FBAR/CPA workpaper suite launches on Dec 15.
Disclaimer: Deterministic mathematical data-aggregation workpaper tool only, not tax, accounting, legal, or investment advice. Always review schedules with a licensed CPA/EA.
Disclaimer: Deterministic mathematical data-aggregation workpaper tool only, not tax, accounting, legal, or investment advice. Always review schedules with a licensed CPA/EA.