Skip to content
Statistical Arbitrage / Backtesting and Validation

Purged K-Fold Cross-Validation: Eliminating Look-Ahead Leakage

A pairs model whose label is "did the spread converge within ten days" will score well in ordinary cross-validation even if its features are noise, and the desk will fund it. Standard kk-fold cross-validation partitions the dataset into kk folds, trains on k−1k-1, and tests on 1, cycling through all folds. In finance this fails: financial returns are serially correlated and overlapping labels (returns spanning multi-day windows) create information leakage from the testing set into the training set. A classifier trained on observations that inadvertently share information with the test set will overestimate its out-of-sample performance — even if the test fold was never explicitly seen during training.
Purged kk-fold CV (López de Prado) fixes this with two operations: purging (removing training observations whose labels overlap with any testing label) and embargoing (removing training observations that immediately follow the test set, whose features still carry test-period information). The interval rule and the exclusion ledger were introduced in Purging and Embargoes. This note keeps that rule and works out what it means for a relative-value book: labels that run from a trade's entry to its exit, a panel in which every stock shares the same dates, and features estimated over a trailing window.
Learning objectives. By the end of this note you should be able to:
  • identify the two sources of leakage in standard k-fold CV (label overlap, serial correlation);
  • define purging and state which training observations are removed;
  • define embargoing and select an appropriate embargo length hh;
  • implement the Purged K-Fold CV procedure algorithmically;
  • apply both operations to a cross-sectional panel and to pair trades with variable holding periods;
  • use the behaviour of the score as kk increases as a check for remaining leakage.

In this lesson

    1. Why standard k-fold CV fails in finance
    1. Purging
    1. Embargoing
    1. Purging a relative-value panel
    1. Effect on k-fold performance estimation

Before you start

The full lesson, with worked examples and exercise solutions, is for members.

Read the full lesson

New to SelfMadeQuant.com? See membership options or browse the Statistical Arbitrage syllabus.