Purged Cross-Validation & Embargo Calculator
Validation geometry
Indices are zero-based and the validation window is inclusive. A label horizon of 5 means row i uses information through row i+5, capped at the sample end.
Leakage-aware split
Purging protects the label boundary
A row can sit outside the validation fold and still leak validation information if its target is computed from a forward window that reaches into the validation period. Purging removes every candidate training row whose label-information interval overlaps the union of the validation labels' information intervals.
For a training interval [t0, t1] and validation information interval [T0, T1], this implementation treats them as overlapping when t0 ≤ T1 and t1 ≥ T0. That is the mechanical leakage condition this calculator exposes.
Embargo adds a second buffer
Purging removes direct label overlap. Embargo removes an additional block of candidate training observations immediately after the validation information interval. The purpose is different: it creates extra temporal separation where nearby observations or features may remain serially dependent even after direct label overlap is gone.
The correct embargo is research-design dependent. This tool accepts an explicit row count rather than claiming one percentage is universally sufficient.
What this check does not prove
Purging and embargo reduce a specific form of validation leakage. They do not make observations IID, repair look-ahead features, fix survivorship bias, reconstruct missing point-in-time data, account for strategy search multiplicity, or create genuinely unseen future data.
Use the PBO / CSCV calculator to test the selection process across complementary splits, the autocorrelation check for serial dependence inside returns, and the Deflated Sharpe Ratio for selection-adjusted Sharpe evidence.
Reusable reference case
The checked-in reference case uses 100 observations, a 5-row forward label horizon, validation rows 40–59, and a 5-row embargo. It retains 65 training rows after removing 10 overlap rows and 5 embargo rows.
Method sources
- Marcos López de Prado, Advances in Financial Machine Learning, Chapter 7, formalizes purging overlapping label intervals and embargoing observations after the test set.
- Financial ML Core: PurgedKFold documents the interval-overlap rule used to remove training labels that intersect the test interval.