Skip to content

Data leakage

Future information entering training — inflated backtests, models that fail in production.

Cite this entry

This reference cites the Cyclepedia entry. The documents it draws on are listed in the entry’s sources.

On this page

Who this is for — Anyone doing ML or backtests on time series. Leakage is the silent error that turns a «perfect» model into live losses.

Data leakage occurs when information not available at decision time enters features, targets or preprocessing — look-ahead bias, shuffling time series, normalizing on the full dataset, joins with data revised ex post.

Canonical treatment: Data leakage and look-ahead bias — causality, preprocessing, audit and the boundary with survivorship bias.

In plain terms — The model «cheats» by seeing exam answers before responding — great on paper, useless live.


Common forms

Type Example
Look-ahead Feature uses current bar close to enter at open
Target leakage Target built with post-event data unknown at t
Global preprocessing StandardScaler fit on train+test together
Survivorship Universe = only stocks still listed today
Revisions Macro «final» instead of first print

In finance time is causal: splits must respect chronology (out-of-sample).


Prevention

  • Features with explicit lags; entries on next bar open
  • Walk-forward and purge between adjacent folds
  • Pipeline audit: «what did I know at t?»
  • Compare to naive baseline — huge jump? suspect leakage

Common mistake — Random `train_test_split` on OHLCV — mixes future and past, unrealistic metrics.

Example — Model predicts gap up: feature includes `high - open` on the same bar you enter at open → leakage, 90%+ accuracy, useless live.

Card

  • Rule: no data from t+1 in decision at t.
  • Test: shift features 1 bar — performance collapses? likely leakage.
  • Related: Overfitting often masks leakage.

Sources