Skip to content
CN2.DEVBUKYA NARESH
DATA7 MIN READNOTE 01

The most common way a backtest lies to you is not a modelling mistake. It is a read that should not have been possible.

Lookahead bias is usually treated as a discipline problem — be careful, don't peek. That framing fails because it depends on a human remembering. The alternative is to make peeking structurally impossible in the data layer, so the strategy code cannot express the mistake even by accident.

01

THE USUAL FRAMING IS WRONG

Most discussions of lookahead bias end with an instruction: make sure your strategy only uses information available at the decision timestamp. This is correct and almost completely useless as a control, because it is a rule about what a developer must remember while writing code that is already complicated.

A rule that depends on discipline fails silently. The failure appears as an unusually good equity curve, which is exactly the outcome a researcher is least motivated to interrogate.

02

WHERE THE LEAK ACTUALLY ENTERS

In practice, leakage rarely enters through the strategy's decision logic. It enters through the data layer: a resampled window that includes the bar being predicted, a join against a table that was last written after the event, a normalization step that used a full-series statistic to scale each point.

Each of these is an infrastructure decision made long before the strategy logic runs. By the time the strategy looks wrong, the cause is several layers away from where the researcher is looking.

03

MAKE IT UNREPRESENTABLE

quant-market-data-replay takes the position that information-flow correctness belongs in the storage and access layer. A query is answered at a point in time, and the access path for anything after that point does not exist. Consumers cannot opt out of the guarantee because there is no code path that returns the future.

The test for this is adversarial rather than illustrative: deliberately attempt to extract future information through every access pattern available and confirm each attempt fails. A test that only confirms correct behaviour does not tell you whether the wrong behaviour is reachable.

The replay instrument in the lab demonstrates the boundary directly — scrub a timestamp and the region that did not exist at that moment is rendered as unreachable rather than merely hidden.

04

WHAT THIS DOES NOT FIX

Point-in-time access guarantees stop leakage at the boundary. They say nothing about a strategy that misuses a resampled window computed above the data layer, and they say nothing about statistical overfitting to one historical window.

The honest position is that this eliminates one failure class completely and leaves the others exactly where they were. That is still worth doing, because a failure class that cannot occur is a failure class that no longer has to be checked by eye.

WHAT THIS NOTE ARGUES

  • Leakage usually enters through infrastructure, not strategy logic.
  • Adversarial tests prove reachability is absent; confirmatory tests do not.
  • The guarantee covers access, not strategy misuse above the boundary.

The limits stated above are part of the argument. If an associated study is still running, the linked research entry notes it.