Purged cross-validation and embargo: stopping overlapping trades from leaking test data into training
Posted: Tue Nov 24, 2026 4:11 pm
Ordinary k-fold cross-validation assumes observations are independent. Trading data isn't, and a subtle way that breaks things is overlapping labels. Suppose each sample is labelled by what happened over the following 30 minutes. A training sample at 10:00 and a test sample at 10:10 share 20 minutes of the same future. The model can learn from the training label something it then gets "right" on the test set, and the cross-validated score looks better than anything you'll see live.
Purging is the fix. For each test fold, you remove from the training set any sample whose label window overlaps the test fold's time span. An embargo goes a step further and also removes a small buffer of training samples immediately after the test fold, because features built from rolling windows can carry information across the boundary too.
For scalping, it's tempting to think this doesn't matter because trades are short. Two reasons it still does:
- Features often use much longer windows than the trades. A feature built on daily ATR or a 200-bar average carries information across a boundary even if the label only spans five minutes.
- Short-term data is dense. A five-minute label on M1 bars still overlaps four neighbours on each side, and with thousands of samples that adds up.
The size of the embargo is a judgment call. A common rule of thumb is a small percentage of the sample, but thinking about the longest lookback in your features is more principled.
The test of whether it matters for your data is simple: run the same model with plain k-fold and with purged k-fold plus embargo, and compare. If the score drops a lot, the plain version was flattering you.
Has anyone here seen a big drop when switching to purged validation? It would be useful to know what kinds of features leak the most.
Purging is the fix. For each test fold, you remove from the training set any sample whose label window overlaps the test fold's time span. An embargo goes a step further and also removes a small buffer of training samples immediately after the test fold, because features built from rolling windows can carry information across the boundary too.
For scalping, it's tempting to think this doesn't matter because trades are short. Two reasons it still does:
- Features often use much longer windows than the trades. A feature built on daily ATR or a 200-bar average carries information across a boundary even if the label only spans five minutes.
- Short-term data is dense. A five-minute label on M1 bars still overlaps four neighbours on each side, and with thousands of samples that adds up.
The size of the embargo is a judgment call. A common rule of thumb is a small percentage of the sample, but thinking about the longest lookback in your features is more principled.
The test of whether it matters for your data is simple: run the same model with plain k-fold and with purged k-fold plus embargo, and compare. If the score drops a lot, the plain version was flattering you.
Has anyone here seen a big drop when switching to purged validation? It would be useful to know what kinds of features leak the most.