#41 — Central trades DB + infrastructure
Hypothesis — what it tests
Engineering: can all trade records — live and paper, across every strategy container — flow into one deduplicated DuckDB so the ledger is queryable, broker-reconciled, and immune to per-container log divergence?
Description
An infrastructure build that fixed a measurement problem: every strategy container had been logging trades to its own JSONL file, so there was no single queryable P&L history and the dashboard had nothing structured to plot. lib/db.py gained is_paper and label columns, an idempotent schema migration, and write_trade_direct() — a direct write path with WHERE-NOT-EXISTS dedup on trade_id and retry on lock contention. A missing fx-db volume mount was found to be the root cause of an empty dashboard (each container had been writing to its own invisible overlay-filesystem copy of the DB). A broker backfill script reconstructed 84 Zone Recovery trades from OANDA transaction history (net +109.7 pips, broker-reconciled), and 106 historical paper trades were imported from JSONL. The dashboard gained a live-vs-paper split equity chart and a paper-strategies section, with the strategy registry made authoritative for enabled/disabled status.
Key result
Algorithms
Interactive version (search, filters, figures): the experiment explorer.