Quant Memo
Core

Preprocessing Leakage in Time-Series Pipelines

How ordinary preprocessing steps — scaling, imputing, computing rolling statistics — can silently leak future information into a time-series model if they're fit on the whole dataset instead of only on data available at each point in time.

Prerequisites: Data Leakage in Machine Learning, Causal Padding and Look-Ahead Leakage

Data leakage in time series usually gets discussed in terms of the obvious mistake — using tomorrow's return as a feature to predict today's. But a subtler and more common version of the same problem hides inside preprocessing steps that look completely innocent: scaling features, filling in missing values, or computing a rolling z-score. Each of these needs some reference statistic — a mean, a standard deviation, a min and max — and if that statistic is computed using the entire dataset, including dates that come after the point being predicted, information from the future has leaked into every single row, even ones far earlier in the sample.

A concrete case: standardizing a feature by subtracting its overall mean and dividing by its overall standard deviation, computed once across the full ten-year dataset, and using that same fixed mean and standard deviation for every row — including data from year one. But the mean and standard deviation of the full ten years necessarily reflect what happened in years two through ten, information that would not have existed yet if you were actually standing in year one making a prediction. A backtest built on data preprocessed this way can look meaningfully better than a real strategy would have performed, because every early prediction was quietly informed by statistics that summarize the future.

The fix mirrors how any leakage problem is fixed: every preprocessing statistic must be computed using only data available as of the point being predicted, and recomputed as new data arrives, exactly the way it would have to be run live. In practice this means fitting a scaler on a rolling or expanding window ending at the current date rather than on the full historical dataset, and refitting it at each step of a walk-forward backtest rather than once at the start.

What this means in practice

Preprocessing leakage is one of the most common ways a time-series backtest quietly overstates performance, precisely because it doesn't look like leakage — nobody used a "future feature," they just standardized the data before splitting it, which feels like routine housekeeping rather than a modeling decision. Any time-series pipeline should be checked to confirm every scaler, imputer, or rolling statistic is fit only on data available at each historical point, not on the dataset as a whole.

Preprocessing steps like scaling and imputation leak future information into a time-series model whenever their reference statistics are computed on the whole dataset rather than only on data available as of each prediction date — a subtle leakage source that looks like routine data cleaning rather than a modeling mistake.

Related concepts

Further reading

  • de Prado, Advances in Financial Machine Learning, ch. 7
ShareTwitterLinkedIn