Concept

Purged Cross-validation

Purged Cross-validation, also known as CPCV, purging & embargo, is a Performance, Backtesting & Validation concept. The Library holds 1 implementation, a working definition you can pull into Quant.

Top Purged Cross-validation indicator

The top custom implementation, built on the original standard Purged Cross-validation formula.

1 total

Want to trade Purged Cross-validation? The implementation below is one prompt away from a backtested strategy in Quant.

What is purged cross-validation?

Purged cross-validation is a modification of standard k-fold cross-validation for financial machine learning, designed to stop information leaking between training and test folds through overlapping labels. Popularized by Marcos Lopez de Prado in Advances in Financial Machine Learning (2018), it adds two operations, purging and embargo: purging deletes from the training set any observation whose label window overlaps in time with a test observation's label window, and the embargo additionally drops a buffer of training observations immediately after each test block to absorb serial correlation that outlives the labels.

The problem it fixes is subtle but severe. Financial labels are usually computed over a forward window, for example the return over the next 20 bars or the outcome of a triple-barrier exit. When ordinary k-fold assigns neighboring observations to different folds, a training sample's label can be built from the very same price path a test sample is judged on. The model is then partly graded on information it saw in training, cross-validated scores inflate, and hyperparameter tuning confidently selects overfit models. Because returns and volatility are serially correlated, even non-overlapping neighbors leak, which is what the embargo addresses.

Traders and quant researchers care because leakage of this kind is a dominant reason machine-learning strategies ace validation and fail live. The combinatorial extension, CPCV (combinatorial purged cross-validation), applies purging and embargo across many train/test block combinations, producing multiple backtest paths instead of one and thereby a distribution of performance rather than a single, easily overfit number.

How traders use it

  • As the default validation scheme when training ML models on financial labels: define each sample's label interval explicitly, purge overlapping training samples around every test fold, and add an embargo of a small percentage of the data after each test block.
  • For hyperparameter tuning, where leakage does the most damage: tuning against leaky folds systematically selects complexity that memorizes shared price paths, so purged folds are used inside the tuning loop, not just for the final score. This is part of broader train/validation discipline.
  • Via CPCV when a distribution of outcomes is wanted: enumerating many purged train/test combinations yields multiple out-of-sample paths, whose spread feeds overfitting diagnostics in the same spirit as the probability of backtest overfitting.
  • With label design done first: purging requires knowing exactly when each label's information begins and ends, so a precise label definition and prediction horizon is a prerequisite rather than an afterthought.
  • Within its limits: purging removes leakage through labels and nearby autocorrelation, but it does not defend against feature engineering that already used future data, nor against overfitting from testing many model variants, which still needs its own correction.

Purged cross-validation vs related concepts

Walk-forward Analysis: Walk-forward respects time by only training on the past, producing a single chronological path that may hinge on one regime sequence. Purged CV uses data in both directions but sterilizes the boundaries, trading some temporal realism for more evaluation paths and better data efficiency.

In-sample / Out-of-sample Split: The single-split ancestor. A chronological holdout avoids most label overlap by construction but yields one test verdict; purged CV generalizes to many folds while controlling the leakage that naive k-fold would introduce.

Model Overfitting: The failure mode at stake. Leaky validation does not cause overfitting by itself, but it hides it, letting an overfit model score well in testing. Purging restores the test's ability to detect the problem.

Concept family

Performance, Backtesting & Validation

30 concepts mapped · 30 in the Library

Purged Cross-validation FAQ

Turn Purged Cross-validation into a trading strategy.

Take the implementation from this page into Quant, then build on it, backtest it on real data, and keep refining it in conversation.