Quant Memo
Advanced

Combinatorial Purged Cross-Validation

A cross-validation scheme that reuses the same purged, embargoed data in many combinations to produce not one backtest path but a whole distribution of them, so you can measure how lucky your single equity curve was.

Prerequisites: Purged & Embargoed Cross-Validation, Cross-Validation for Time Series

A single backtest gives you a single equity curve, which is a single draw from a distribution you never get to see. Maybe the strategy is good; maybe that one path just happened to dodge the bad patches. Ordinary Walk-Forward Analysis testing suffers this badly: it produces exactly one out-of-sample path, so you can't tell skill from luck. Combinatorial Purged Cross-Validation (CPCV), from López de Prado, squeezes many out-of-sample paths out of the same data, turning your one equity curve into a whole distribution you can actually reason about.

The idea builds directly on Purged & Embargoed Cross-Validation: it keeps the purging (drop training labels whose forward windows overlap the test block) and the embargo (drop a buffer after it), then adds combinatorics on top.

How it works

Split the time series into NN equal, ordered groups. Instead of testing on one group at a time, test on every combination of kk groups at once, purging and embargoing each. There are (Nk)\binom{N}{k} such combinations. Because each combination leaves a different set of groups for testing, you can stitch the test predictions together into complete, start-to-finish backtest paths, and it turns out you get many of them. The number of distinct paths is

φ[N,k]=kN(Nk).\varphi[N, k] = \frac{k}{N}\binom{N}{k}.

Here NN is how many groups you carve the timeline into, kk is how many you hold out for testing in each combination, and (Nk)\binom{N}{k} is "NN choose kk", the count of ways to pick those kk groups. Each of the φ\varphi paths is a full equity curve built from models that never saw their own test data (thanks to purging and embargo), so you end up with φ\varphi Sharpe ratios instead of one.

CPCV tests on all (Nk)\binom{N}{k} combinations of kk held-out groups and reassembles them into φ=kN(Nk)\varphi = \frac{k}{N}\binom{N}{k} full backtest paths. One equity curve becomes a distribution of equity curves, so you can measure the spread of your result, not just its center.

The table shows how quickly paths accumulate. Testing one group at a time (k=1k=1) recovers plain k-fold and gives just one path; holding out two or more groups unlocks many.

Groups NNHeld out kkCombinations (Nk)\binom{N}{k}Backtest paths φ\varphi
6161
62155
102459
105252126

A modest number of groups yields a rich set of backtest paths. With 6 groups holding out 2, the same data produces 15 train/test splits that reassemble into 5 full-length out-of-sample paths.

Worked example

Take N=6N = 6 groups and hold out k=2k = 2 at a time. There are (62)=15\binom{6}{2} = 15 ways to choose the test pair, so you train and evaluate 1515 models (each with the overlapping labels purged and a buffer embargoed). Those 15 splits recombine into φ=26×15=5\varphi = \tfrac{2}{6}\times 15 = 5 complete backtest paths.

Now instead of one Sharpe you have five, say {0.9, 1.3, 0.4, 1.1, 0.7}\{0.9,\ 1.3,\ 0.4,\ 1.1,\ 0.7\}. Immediately you know things a single number could never tell you: the mean is about 0.880.88, but the spread runs from 0.40.4 to 1.31.3. If your reported single-path Sharpe had been the 1.31.3, you'd now see it was the lucky top of the range, not typical. You can also count how often the strategy's in-sample best configuration underperforms out-of-sample across these paths, which is precisely the ingredient for estimating the probability of Backtest Overfitting.

Report the whole distribution of path Sharpes, its median and its spread, not the single best path. The gap between the best path and the median is a direct read on how much luck was in your headline number.

Pitfalls

  • Paths are not independent. The φ\varphi paths share data and overlapping models, so their Sharpes are correlated. Treat the spread as an honest picture of variability, not as φ\varphi independent samples for a tight confidence interval.
  • Purge and embargo still mandatory. CPCV without purging leaks exactly like naive k-fold; the combinatorics multiply the leakage rather than fixing it. See Purged & Embargoed Cross-Validation.
  • Cost. You train (Nk)\binom{N}{k} models, which explodes for large NN and mid-range kk. Choose NN and kk for enough paths (a few dozen) without a runaway model count.
  • Group size vs label span. Groups must be long relative to the label horizon from Triple-Barrier Labeling, or purging eats most of each fold.

More paths is not more data. CPCV reuses the same observations in different arrangements, so the paths are correlated. It reveals the variability of your backtest honestly, but it cannot manufacture statistical power you don't have, that still needs a longer sample.

In interviews

If asked "how do you know your backtest's Sharpe wasn't a fluke of one particular data path?", the strong answer is CPCV: partition into NN groups, test on all (Nk)\binom{N}{k} combinations with purging and embargo, and reassemble φ=kN(Nk)\varphi = \frac{k}{N}\binom{N}{k} out-of-sample paths to get a distribution of Sharpes. Note that this distribution is what feeds the probability-of-backtest-overfitting estimate, and that the paths are correlated so you shouldn't oversell their precision.

Related concepts

Practice in interviews

Further reading

  • López de Prado, Advances in Financial Machine Learning (Ch. 12)
  • Bailey, Borwein, López de Prado & Zhu, The Probability of Backtest Overfitting
ShareTwitterLinkedIn