Purged cross-validation removes training observations whose label intervals overlap the test labels. An embargo excludes an additional, declared period of later training observations to reduce remaining dependence. In crypto research, both rules need actual label start and end times: splitting only by row timestamp can leave future prices shared across training and testing. Neither rule makes a retrospective split a simulation of live deployment.
A model predicting a three-hour return does not have a point-sized outcome. Its label uses prices across time. A training row can therefore sit outside a test block while borrowing part of the same market move. The practical question is which observations must be excluded from each fit, and why.
Give every label an interval
For each observation, save its decision time, label end time and label availability time. A fixed-horizon label might end three hours after the decision. An event-based label might end when a barrier is reached or a maximum holding period expires. Use the actual end, rather than assuming every event lasts equally long.
Here, a label interval is the closed interval [start, end]. Two intervals overlap when training_start <= test_end and training_end >= test_start. This deliberately conservative convention treats a shared endpoint price as overlap. Some implementations use half-open intervals; document that choice and check the observations used at the boundary rather than translating inequalities mechanically.
MLFinLab's PurgedKFold interface documentation describes purging training observations that overlap test-label intervals, and records the information range associated with each sample. Its published interface assumes a contiguous test set. That is a useful scope boundary when comparing implementations.
Keep label construction separate from signal causality. The look-ahead bias guide examines whether a decision uses unavailable inputs. This article assumes those inputs have already passed that check and focuses on overlap between the outcomes used for model fitting and evaluation.
Work through one fold before trusting the splitter
Consider an invented hourly dataset on one UTC date. The test observations start at 10:00, 11:00 and 12:00; their respective three-hour labels end at 13:00, 14:00 and 15:00. Their label intervals overlap one another, so the combined test information interval is [10:00, 15:00].
Assume a retrospective fold that may use training candidates on either side of testing. For this illustration, the declared embargo excludes candidate starts in [15:00, 18:00): a three-hour buffer measured from the latest test-label end. This is an example convention, not a recommended duration or a claim about every library's embargo anchor.
| Candidate | Label interval, UTC | Overlaps test labels? | Start inside embargo? | Treatment |
|---|---|---|---|---|
| A | 06:00–09:00 | No | No | Retain |
| B | 07:00–10:00 | Yes, shared endpoint | No | Purge |
| C | 09:00–12:00 | Yes | No | Purge |
| D | 13:00–16:00 | Yes | No | Purge |
| E | 15:00–18:00 | Yes, shared endpoint | Yes | Exclude once; record both reasons |
| F | 16:00–19:00 | No | Yes | Embargo |
| G | 17:00–20:00 | No | Yes | Embargo |
| H | 18:00–21:00 | No | No | Retain |
Four candidates meet the purge rule and three meet the embargo rule. E belongs to both sets, so the number excluded is 4 + 3 - 1 = 6, leaving two of eight candidates. Adding the two counts without deduplication would incorrectly report seven exclusions. These counts describe this tiny teaching example, not the expected data loss of a real strategy.
Notice D. Its decision occurs after the last test decision at 12:00, yet its label overlaps test outcomes through 15:00. An implementation that considers only the test decision timestamps misses it. Notice H too: its start equals the exclusive embargo endpoint, so this convention retains it.
Purging and embargo answer different questions
Purging is an interval-intersection test. It identifies the training labels that share the declared test information period. An embargo is an additional exclusion policy for later candidates, intended to reduce dependence that remains after direct overlap is removed. It does not prove that serial dependence has disappeared.
State the embargo's anchor, units and endpoints. “One percent embargo” is incomplete without the denominator and the rule converting that percentage into observations. Ten rows can represent ten minutes in one dataset and several hours in another. For irregular events, save the resulting excluded timestamps as well as the parameter.
Choose a buffer from the pipeline's actual dependencies, then examine reasonable alternatives without selecting whichever gives the highest score. A trailing feature can legitimately use history available at its decision. A feature lookback is therefore not automatically an equal-sized ban on test observations. Conversely, later training features that reuse test-period information may require a separate information-range audit or a longer declared exclusion policy.
If test labels occupy disjoint time blocks, compare against their union of intervals. Replacing that union with one interval from the earliest start to the latest end can discard otherwise eligible observations in the gaps. Some splitters deliberately use a conservative span; report that behavior rather than calling it an exact overlap count.
Preserve the distinction from walk-forward testing
A purged retrospective fold can train on observations later than its test block. Removing label overlap does not change that chronology. Such a fold studies relationships across historical partitions; it does not reconstruct what a trader could have fitted before the test period began.
For deployment timing, use the separately defined walk-forward procedure, and require training labels to be complete and available at the historical model freeze. A label ending at 09:59 but delivered at 10:02 is unavailable for a 10:00 fit even when an interval-only purge would retain it.
Scikit-learn's TimeSeriesSplit documentation defines its gap as observations removed from the end of training before testing. That is a different location from the post-test embargo illustrated above. Neither parameter name nor chronological row order substitutes for checking actual label completion and receipt times.
Keep an exclusion receipt for every fit
Save a compact worksheet alongside each fold's results:
| Receipt field | What it must make reproducible |
|---|---|
| Observation identity | Instrument, venue or data source, decision time and stable row ID |
| Label definition | Start, actual end, availability time and endpoint convention |
| Test membership | Exact IDs and union of test-label intervals |
| Exclusion membership | Purged IDs, embargoed IDs, intersection and retained IDs |
| Embargo rule | Anchor, elapsed-time or row-count units, duration and endpoints |
| Fit record | Retained-data hash, transformation fit, model version and objective |
Fit scalers, imputers and feature selection using only the retained training rows. Scikit-learn's data-leakage guidance explains why transformations learned from test data contaminate evaluation. A correct splitter cannot repair a scaler fitted earlier on the complete dataset.
For pooled crypto instruments, audit overlap across the combined dataset rather than purging each coin in isolation and assuming independence. Shared timestamps, market factors and cross-asset features can connect observations. Removing temporal overlap still does not establish that retained assets or outcomes are statistically independent.
A fold may become unusable after exclusions: it can have too few observations or lose a class required by the estimator. Record that failure and apply a predeclared handling rule. Quietly shortening the embargo or dropping a difficult fold changes the experiment after seeing its consequences.
Report what the remaining evidence represents
Keep exclusion counts beside each score. A high score from two retained training observations deserves a different interpretation from one based on a substantial, well-defined sample. Log alternatives in the backtest trial record; repeated selection can overfit even perfectly separated folds.
If predictions become a trading simulation, apply a separate ledger for the equity snapshot used to size each order. Purging labels does not supply observable capital or valid fills. When comparing resulting portfolios, also preserve the time and capital denominators behind exposure-adjusted returns. Excluding research observations does not itself mean the portfolio was out of the market during those hours.
Method and limits
This AI-assisted article uses the linked primary software documentation and an original interval worksheet. All times, candidate rows and the three-hour embargo are hypothetical. The table's overlap flags and set counts were recomputed. No market dataset, trained model, KLINEO simulation or live order was tested. These checks support an inspectable validation protocol; they do not establish predictive accuracy, executable returns or future performance.
