Cross-validation tests a model by repeatedly training it on part of the data and scoring it on the rest. In finance, ordinary k-fold cross-validation leaks information because returns overlap in time, so researchers use purged and embargoed versions.
Why ordinary k-fold fails
- Data is ordered. Shuffling rows lets the model train on the future to predict the past.
- Labels overlap. If each label is the return over the next 5 days, observations on Monday and Tuesday share four days of the same return, so a training row can contain nearly the same information as a test row.
An illustrative example
Suppose labels are 5-day forward returns and the test fold covers days 100 to 120. A training observation from day 97 has a label that runs to day 102, inside the test period.
| Technique | What it does |
|---|---|
| Purging | Removes training observations whose labels overlap the test period, here days 96 to 99 and any after the fold's start |
| Embargo | Also drops a short period after the test fold, since serial correlation links it to the test data |
| Combinatorial purged CV | Tests many train/test combinations to get a distribution of backtest paths, not just one |
These techniques are described in Lopez de Prado (2018).
Where it fits
- It is used to tune and compare models, such as in machine learning in investing.
- It complements walk-forward testing, which respects time order strictly, and out-of-sample testing.
- It protects against look-ahead bias and overfitting.
Cautions
Even with purging, repeated use of the same data to choose models leads to data snooping. A final untouched hold-out period is still needed.
Frequently asked questions
Why can't normal k-fold cross-validation be used for financial data?
Because returns are time-ordered and labels overlap, so training data can contain information from the test period, inflating results.
What is purging in cross-validation?
Removing training observations whose labels overlap in time with the test set.
What is an embargo?
A gap after the test set during which observations are excluded from training to avoid leakage through serial correlation.
Is cross-validation better than walk-forward testing?
They serve different needs. Walk-forward respects time strictly and mimics live use, while purged cross-validation uses data more efficiently.