A live trading system fails silently long before it fails loudly, because its output — a P&L that wiggles anyway — masks bugs that any normal program would surface in minutes. The only reliable detector is reconciliation: forcing the research code, the live engine, and the broker's records to agree, every day, on signals, positions and fills, and treating any disagreement as a defect until proven otherwise.
The idea
Here is the failure mode this lesson exists to prevent. You deploy your strategy. It runs for six weeks. The P&L is a bit below the backtest but within the range you'd shrug at — markets are noisy, you tell yourself. Then one evening, poking at something unrelated, you notice that your daily bars roll at midnight UTC while the signal logic was written assuming exchange close. Every signal for six weeks has been computed on bars that end five hours before the close, quietly missing the last five hours of every trading day. Nothing crashed. No exception was thrown. The system did exactly what the code said, and the code was wrong, and the market's noise was deep enough to hide it.
As a software engineer you already know the general principle — silent wrongness is worse than loud failure — but trading systems have a property that makes them uniquely hostile territory for it. In most software, wrong output is visibly wrong: the page renders garbage, the API returns the wrong record, a user complains. A trading system's output is a number drawn from a distribution whose standard deviation is enormous relative to the signal. A bug that costs you 30 basis points a month is a catastrophic bug — it can be most of your edge — and it is statistically invisible in the P&L for months, because 30 basis points is a rounding error against daily noise. The market is, in effect, a random number generator wired across your test output. You cannot eyeball your way to correctness. Perold's paper-versus-reality gap (Perold 1988) is usually discussed as a cost problem (module 3), but its first application is diagnostic: the gap between what the paper portfolio did and what the real one did is a measurement channel, and it's the only one you have.
So you build what testing folk would call an oracle. You have three descriptions of what your strategy did today:
- The research implementation — the backtest code, run over data up to today, producing today's signal and target positions. This is the specification.
- The live engine — whatever actually computed signals and sent orders this morning. This is the implementation.
- The broker's records — positions and fills as the outside world saw them. This is reality.
Reconciliation means diffing these three, pairwise, every day, and it splits naturally into three reports:
The signal diff (research vs live). Feed the research code the same calendar date the live system traded and compare the raw signals and target weights, instrument by instrument. In a healthy system this diff is exactly zero — not small, zero — whenever both stacks saw the same data. Anything nonzero means the two programs disagree about what the strategy is, and one of them is wrong. This is the diff that catches the timezone bug, the stale cache, the off-by-one in a rolling window.
The position diff (live targets vs broker holdings). Did the orders the engine intended actually result in the book it thinks it has? Rounding to lot sizes, partial fills, rejected orders, an instrument that got halted — all legitimate reasons for small gaps, which is why this diff has a tolerance, and the tolerance should be expressed in risk, not in shares (more below). A position diff that grows over days is an engine that is slowly losing track of reality.
The fill diff (assumed execution vs actual fills). The backtest assumed you traded at some price — close, open, mid at 10:00. The broker tells you what you actually paid. The difference, trade by trade, is your realised cost, and accumulating it is how you build the cost model that module 3 says you need and lesson 10.2 will consume. This diff is never zero; its job is to be measured, not eliminated.
Notice what paper trading is for, in this framing. It is not for finding out whether the strategy makes money — six weeks of paper P&L is statistically meaningless for that purpose (lesson 2.6 does the arithmetic; the short version is that at realistic Sharpe ratios you'd need years). Paper trading is a plumbing test: it exercises the full pipeline — data in, signals computed, orders generated, state persisted, restarts survived — with the reconciliation harness running, until the three-way diff has been clean for long enough that you trust the pipes. You are testing the system, not the alpha. Expecting paper trading to validate the alpha is the single most common misuse of it.
A field guide to silent breakage
Worth cataloguing the enemy, because the same handful of failure classes account for most quiet divergence. Every one of these is a bug I'd describe as typical rather than exotic:
Your history changes under you. You think of the vendor's price history as immutable. It is not. Vendors restate bad prints, switch a series between adjusted and unadjusted, remap symbols after corporate actions, backfill gaps. Your signal today is a function of a trailing window; if the window's contents changed since yesterday, your signal can change about the past. Detection: periodically recompute signals over a trailing window and diff against what you computed at the time — or cheaper, hash a snapshot of the trailing data each night and alert when a hash for an already-seen date changes.
Timezones and calendars. Daylight-saving transitions move your bar boundaries twice a year — and the US and UK change on different weeks in March and October–November, so cross-market strategies have two windows a year where the offset between your markets is not what your code assumed. Holiday calendars, half-days, and exchanges that moved their close. These bugs are seasonal: they appear, wreck two weeks of signals, and vanish before you've isolated them.
Corporate actions. A 10-for-1 split arrives and your unadjusted feed shows a −90% overnight "return". Best case, a sanity check trips. Worst case, it flows into a volatility estimate, your vol-targeted position size decuples the day after (the same failure that lesson 10.3's warden exists to catch), or a momentum signal reads it as a crash. Dividends handled in the backtest's total-return series but missing from the live feed produce a slow, systematic drag on the signal diff — the nastiest kind, small and persistent.
Stale state. A websocket reconnects after a gap and nobody replays the missed messages. A cached instrument list doesn't include the contract that started trading last month. The process restarts mid-day and reloads yesterday's vol estimates. Live systems are stateful in ways backtests are not, and every piece of state is a place where live can drift from research without anything being "wrong" in either codebase.
Schema and API drift. The broker's API changes the sign convention on short positions, or starts reporting P&L in account currency instead of instrument currency, or renames a field. Your parser doesn't crash — it reads the wrong field, or applies the old semantics to new data.
Universe drift. A ticker changes after an acquisition. The live system holds the renamed instrument; the research universe no longer contains it; the signal diff shows a phantom position neither side can explain.
Alerting for a system nobody is watching
You run this alone, which means the system operates unattended almost always. Three design rules.
Fail closed, and never trust the patient to report its own illness. The most important alert is a heartbeat with a dead-man's switch: the system emits "I am alive and reconciled" after each cycle, and a separate process — cron on another machine, a cheap external monitor — alarms on absence. If your alerting depends on the broken system successfully sending an email, a hung process is indistinguishable from a healthy quiet one. The Knight Capital story in lesson 10.3 turns on exactly this: the warning emails existed and nobody was primed to read them.
Respect the alert budget. An alert that fires weekly on false positives trains you, within a month, to ignore it — and then the real one arrives dressed identically. Aim for a false alarm rate of at most one or two a month. Everything else goes into a daily digest you read with coffee, not a page that interrupts you.
Make every alert actionable. "Position diff exceeds tolerance on ZN" with the two numbers and a link to the runbook beats "reconciliation warning". At 7 a.m., pre-caffeine, you will do exactly what the alert text tells you to do and nothing more.
The maths
The mathematics of reconciliation is mostly the mathematics of where the statistical power lives, and it contains the one genuinely important insight of this lesson.
Suppose a bug leaks per day out of your P&L — a systematic drag from mispriced fills, a skewed signal, a dividend leak. To detect a mean shift of size against noise of standard deviation at roughly 95% confidence, you need on the order of
observations, where is trading days, is the daily standard deviation of whatever series you're testing, and the daily leak. The formula is just the two-sigma detection threshold rearranged; nothing deep. The insight is in what you choose as the series.
If you test the raw live P&L, is your strategy's full daily volatility. Take a book running 12% annualised vol: basis points a day. A 2bp/day leak — which annualises to roughly 5%, i.e. an edge-destroying catastrophe — needs days. Twenty-two years. The market's noise makes a catastrophic bug undetectable within your lifetime as a trader.
If instead you test the diff between live and the shadow research run, the market's contribution cancels — both series held (nearly) the same positions through the same prices — and collapses to the residual jitter of fills and timing, perhaps 5bp a day for a slow strategy. The same 2bp leak now needs days. Five weeks.
Same bug, same statistics, a five-hundred-fold difference in detection time, purely from differencing out the noise before testing. This is why reconciliation is not bookkeeping pedantry; it is the only statistically feasible way to notice that something is quietly wrong. Test the diff, not the P&L.
One more piece of arithmetic: tolerances. Express position tolerances in risk units, not shares. A 100-share gap in a sleepy utility and a 100-share gap in a crypto-adjacent momentum name are wildly different events. Define the tolerance per instrument as
where is the weight gap on instrument and its annualised volatility — i.e. alert when the risk carried by the discrepancy, not the share count, matters.
Worked example
A ten-instrument futures book, nightly report, three sections. Signal diff first (research recomputed for today vs what the live engine logged this morning):
| Instrument | Research target w | Live target w | Diff (bp of NAV) | Risk of diff (bp vol) |
|---|---|---|---|---|
| ES | +12.0% | +12.0% | 0 | 0.0 |
| ZN | +18.0% | +18.0% | 0 | 0.0 |
| GC | −6.0% | −6.0% | 0 | 0.0 |
| CL | +4.5% | +5.1% | 60 | 2.1 |
| EURUSD | −8.0% | −8.0% | 0 | 0.0 |
Nine instruments agree to the basis point. CL disagrees by 60bp of NAV — small in money, but the report flags it because the signal diff should be exactly zero, and any nonzero entry is a defect, not a tolerance question.
The investigation, engineer-to-engineer: the live CL signal was computed from a price series that converted contract value to account currency using this morning's FX rate; the research code used yesterday's close rate, as the backtest always had. Most days the two rates differ by nothing that survives rounding — the diff had been zero for weeks. Today the pound moved 90 pips overnight and the discrepancy finally cleared the reporting threshold. The bug had been there since launch: live was trading a subtly different strategy from the one that was backtested, invisibly, except on big FX days — which are exactly the days position sizes matter most.
The harness that produces the report is not sophisticated:
# nightly_recon.py — runs post-close from cron; illustrative
research = run_backtest_engine(universe, data_through=today) # oracle
live = load_live_engine_log(today) # what ran
broker = fetch_broker_positions() # reality
sig = (research.targets - live.targets) # must be 0
pos = (live.targets - broker.weights) # tolerance
fills = join_fills(live.orders, broker.fills) # cost meas.
risk_bp = (pos.abs() * vols).sum() * 1e4
report(signal_diff=sig[sig != 0],
position_diff=pos[(pos.abs() * vols) > TOL],
cost_today=(fills.exec_px - fills.model_px)
.mul(fills.qty).sum())
if (sig != 0).any() or risk_bp > HARD_TOL:
page("recon break — see report") # actionable, with numbers
else:
heartbeat("recon clean") # absence of this also alertsThe fill section of the same report, accumulated over the month, is your measured cost per trade — the input lesson 10.2 needs before it can say anything about whether the edge is real.
How you'd use it
A deployment sequence, in order, before the first real order:
- Build the shadow harness first. The research engine must be runnable as an oracle on demand, against live data, producing today's targets. If your research and live code share signal libraries, good — fewer divergence sources — but then the data path must be independent, or you have one bug in two places (see below).
- Paper trade until the diff is boring. Twenty consecutive clean trading days is a reasonable bar: it spans a month-end, usually an economic announcement, and enough restarts to test state handling. A DST transition or contract roll during the window is a bonus, not a nuisance — those weeks are the test.
- Automate the nightly report with the alert-budget discipline: page on signal diffs and hard tolerance breaches, digest everything else.
- Weekly, recompute the full trailing history and hash-compare against last week's computation, to catch vendors editing the past.
- Keep the reports. Twelve months of clean reconciliation reports are also the evidence base you'll need when live returns diverge from the backtest and you have to decide — lesson 10.2 — whether the problem is costs, data, or a dead edge. Without them, that question is unanswerable, and lesson 10.4's kill decision becomes guesswork.
Rob Carver's book (Carver 2015) is good on the temperamental side of this: systems you can't stop fiddling with are systems whose reconciliation reports mean nothing, because the strategy itself is a moving target.
What goes wrong
The oracle shares the bug. If the research and live systems import the same mispriced-dividend handling from the same shared library, the signal diff is a clean, reassuring zero while both are wrong together. Differential testing only detects differences. Defend by making the data path independent even where code is shared (research reads vendor A or raw files; live reads the broker feed), and by the weekly history-hash check, which needs no oracle at all. Full independence — two implementations — is the gold standard and usually too expensive for one person; know which compromises you've made.
Tolerance creep. A noisy alert fires; the fastest fix is widening the tolerance; repeat quarterly and within a year the position diff tolerates a percent of NAV and detects nothing. Tolerances are part of the spec — change them the way you'd change the strategy, deliberately and in writing (lesson 1.10's discipline applies to ops too).
Paper fills flatter you. Paper trading fills at mid, or at your assumed price, with no rejections and infinite liquidity. The plumbing test passes while the cost assumption quietly fails. That gap is precisely the fill diff — it only becomes measurable once real orders flow, which is one reason to go live small rather than paper trade forever: beyond the plumbing-validation window, paper trading generates no information a backtest didn't already contain (Perold 1988).
Reading the paper P&L as evidence. Six good weeks of paper trading feels like confirmation. It is a coin flip's worth of information about the edge (lesson 2.6), and treating it as validation is a small, self-administered dose of the backtest-overfitting disease (López de Prado 2018) — you'll deploy with more confidence than the data supports, and size accordingly, which is how plumbing tests turn into drawdowns.
Nobody reads the clean reports. After three quiet months, the nightly digest becomes background. That's fine — that's what the digest is for — provided the loud path (dead-man's switch, signal-diff page) is tested. Fire-drill it: once a month, break something on purpose in the paper environment and confirm the page arrives. An alerting path that has never been exercised is a hypothesis, not a system — the same doctrine as the kill switch in lesson 10.3.