Quant research and backtesting
Leakage
Also called data leakage, information leakage, target leakage
Information that would not be available at prediction time entering the training or testing of a model, giving performance estimates that are too high.
How it works
Leakage is information that would not be available at prediction time getting into the training or evaluation of a model. The result is a performance estimate that is too high, and a model that does worse when it trades. Kaufman, Rosset and Perlich (KDD 2011) define it as the use of information that should not legitimately be available to the model, and name its most common case the no-time-machine requirement: a model may only use information from before the moment of prediction.
It gets into trading research in five common ways. Lookahead in features: using a close price to trade at that close, or fundamentals before their release date. Overlapping labels: a 20-day forward return label for a day just before the test period covers days inside it, so training and test share outcomes; purging and an embargo in cross-validation remove these rows. Preprocessing on all the data: scaling, imputing, PCA or feature selection fitted before the split. Tuning on the test set: picking hyperparameters or the stopping point by test score, then reporting that score. Choosing the universe with hindsight, such as today's index members.
Scikit-learn's guidance is to split first and fit every transformer on the training data only, using a pipeline so cross-validation refits it each fold. Their worked example makes the point sharply: with 10,000 random features and a random target, selecting 25 features on all the data before splitting scores 0.76 accuracy, while selecting on the training set only scores about 0.5, which is chance.
Why it is distinct from overfitting: overfitting fits noise in legitimate data and shrinks with regularisation or more data. Leakage uses data the strategy could never have had, so no regularisation fixes it. Kaufman and coauthors suggest tagging each record with legitimacy information, such as when it became available, and keeping learning and prediction apart by those tags.
Worked example
A model z-scores each feature with the mean and standard deviation of 2010 to 2024, then trains on 2010 to 2019 and tests on 2020 to 2024. The test period's mean and volatility have entered every training row. Fitting the scaler on 2010 to 2019 only removes the leak. A label leak: with 20-day forward returns and a test set starting 1 January 2020, the last 20 trading days of 2019 carry labels built from January 2020 prices. Dropping those 20 training rows (purging) removes it.
In an interview
"Your model has an out-of-sample hit rate of 58% on daily stock returns. What leakage would you look for?"
A 58% daily hit rate is high enough to suspect a leak first. I would check five things. Timestamps: is every feature available before the decision time, including fundamentals by release date and prices at the time you could trade? Labels: do multi-day forward-return labels in training overlap the test period? If so, purge those rows and add an embargo. Preprocessing: were scalers, imputers or feature selection fitted on all the data? Scikit-learn's example shows feature selection on random data giving 0.76 accuracy when done before the split versus 0.5 after. Tuning: was the test set used to choose hyperparameters? Universe: was it chosen with hindsight? The follow-up is often how to prove there is no leak: rerun with a shuffled target and expect chance, then paper trade.
Related terms
Put it to work in a timed game.
Practise with Find the BugSources
- scikit-learn.org/stable/common_pitfalls.html
- en.wikipedia.org/wiki/Leakage_(machine_learning)
- doi.org/10.1145/2020408.2020496
Last checked November 2026.