Concept
Purged Cross-validation
Purged Cross-validation, also known as CPCV, purging & embargo, is a Performance, Backtesting & Validation concept. First implementations are in the build queue: the write-up leads, the indicators follow.
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.
Related concepts · Validation methodology
Concept family
Performance, Backtesting & Validation
30 concepts mapped · 30 in the Library
Purged Cross-validation FAQ
Why is ordinary k-fold cross-validation wrong for market data?
Because observations are not independent. Forward-looking labels overlap across neighboring samples, and returns are serially correlated, so random fold assignment lets training folds contain information about test outcomes. Scores inflate and model selection is corrupted.
How large should the embargo be?
There is no closed-form answer; a common starting point is a small fraction of the dataset, on the order of 1%, after each test block, enlarged if features or labels have long memory. The right size depends on how far serial dependence extends beyond the label window.
What is CPCV and why use it?
Combinatorial purged cross-validation splits history into blocks and evaluates every combination of test blocks, with purging and embargo applied at each boundary. It produces many out-of-sample paths instead of one, giving a distribution of performance that is harder to overfit to than a single backtest.
Does purging remove the need for other overfitting checks?
No. Purging fixes leakage inside one validation run. Selection bias from trying many features, labels, and models across runs is untouched, so multiple-testing corrections and forward confirmation remain necessary.
How do I know which samples to purge?
Track, for every sample, the timestamps over which its label is determined, such as entry and exit times under a triple-barrier scheme. Any training sample whose interval intersects a test sample's interval is purged; without recorded label intervals, purging cannot be done correctly.
Build Purged Cross-validation your way.
Quant writes, tests, and refines it with you — then it runs on LuxAlgo charting or ports to TradingView.