When two samples share part of the future
Work through event intervals, inclusive boundaries and an explicit embargo to distinguish purged cross-validation from a chronological forecasting test.

At 09:30, a research notebook creates a training row. Its target asks what happens to a price before 10:30. At 10:00, the notebook creates a test row whose target depends on the following hour. The rows sit on opposite sides of a tidy vertical line, yet both answers consult the market between 10:00 and 10:30. Moving the line or sorting the index has not separated those answers.
This is a specific problem with event labels: the timestamp of a row is not its information interval. A target can be attached to the moment a prediction would be made while requiring later observations to determine its value. Those later observations can also determine a target in another fold. A fold is simply one of the groups temporarily assigned to training or evaluation during cross-validation.
We will follow one hypothetical session, preserving the same times throughout. No prices, trades or results come from Atlas or a live strategy. The calculations establish which observations satisfy stated rules; they do not establish a forecasting advantage. The useful output is a decision record: why a row was retained, purged, embargoed or unavailable at the proposed training time.
1. Give every observation more than one clock
For each event, record its decision time, the end of the observations used by its label, and when that completed label became available. These clocks answer different questions. A prediction made at 10:00 could concern an event that ends at 11:00, while the data needed to verify the outcome arrive at 11:10. A model fitted at 11:05 cannot legitimately use that outcome merely because its event has already finished.
We will denote a label interval by a start and an end, both included. This is a deliberately conservative convention for the example. It treats a shared endpoint as shared information. A different label construction might use half-open intervals or intervals of price increments instead of price observations. That alternative is possible, but the boundary rule must follow the actual construction and remain consistent in the code, diagrams and report.
Features have their own clocks. A trailing statistic can inspect prices before the decision; a published economic value can refer to an earlier period while arriving after the decision. Neither the age of the reference period nor the name of a dataframe column proves that the feature was available. Availability is a separate condition, checked against the instant at which the model would consume the value.
In our session, all times are UTC on the same hypothetical trading day. Raw price observations are assumed available at their stated times. Completed labels become usable ten minutes after their recorded ends. This artificial delay makes the distinction visible without claiming anything about an actual data provider. The default feature window is the closed thirty-minute interval ending at each decision time.
Keep the event identifier alongside all these fields. If a target ends early because a hypothetical barrier was reached, its realized end belongs in the interval metadata. It must not quietly become a predictive input. Knowing offline when an outcome finished helps audit a split; pretending that duration was known when the prediction was made changes the experiment.
2. Build the split from intervals, not adjacent rows
The test fold contains T1, T2 and T3. Their decision times are 10:00, 10:30 and 11:00, and their labels end at 11:00, 11:30 and 12:00 respectively. Together, their closed intervals cover 10:00 through 12:00 without a gap. Ten other events are initially candidates for training in a nonchronological cross-validation exercise. That phrase matters: some candidates occur after the test period.
| Event | Decision UTC | Label end UTC | Role before filtering |
|---|---|---|---|
| A | 08:30 | 09:30 | Training candidate |
| B | 09:00 | 10:00 | Training candidate |
| C | 09:30 | 10:30 | Training candidate |
| D | 09:45 | 12:15 | Training candidate |
| T1 | 10:00 | 11:00 | Test |
| T2 | 10:30 | 11:30 | Test |
| T3 | 11:00 | 12:00 | Test |
| E | 11:45 | 12:30 | Training candidate |
| F | 12:00 | 12:45 | Training candidate |
| G | 12:15 | 12:45 | Training candidate |
| H | 12:30 | 13:00 | Training candidate |
| I | 12:45 | 13:15 | Training candidate |
| J | 13:00 | 13:30 | Training candidate |
For two closed intervals, overlap exists when the later start is no later than the earlier end. Written using a training event i and a test event j, the rule is:
max(si, sj) ≤ min(ei, ej)
This is an interval identity, not a forecast or statistical estimate. It catches an event starting inside the test interval, ending inside it, or enclosing it entirely. An implementation that checks only whether a training start falls inside the test fold misses C and D. Checking only the end misses an interval that encloses the whole test window. The two-sided condition avoids those separate special cases.
The union of test intervals is the appropriate object for our rule. Here it happens to equal one continuous interval, so comparing candidates with 10:00–12:00 is exact. If test groups were separated by a genuine gap, replacing their union with one large envelope could discard additional rows unnecessarily. A conservative envelope can be a declared policy, but it should not be mistaken for the exact pairwise intersection calculation.
The latest test decision is 11:00; the protected label window ends at 12:00. Using the last row’s timestamp as the right boundary would miss part of the information used to mark the test answers. Variable event lengths make this distinction especially important: the latest ending label need not belong to the latest starting event.
3. Purge the five events that share label information
Applying the closed-interval rule removes B, C, D, E and F from training. B ends exactly when T1 starts, so it shares the 10:00 endpoint. C overlaps the first half-hour of T1. D surrounds the entire test window. E overlaps its final fifteen minutes, and F starts exactly at its final endpoint. These are five different geometric situations with the same decision: exclude the training event for this split.
A survives because its label ends at 09:30, before any test label starts. G, H, I and J also survive the label-overlap calculation because they start strictly after 12:00. That leaves five training candidates after purging. It does not yet make all five admissible under our complete procedure, and it certainly does not make them historical information available at 10:00.
Purging removes intersecting training labels. The official OpenQuant cross-validation documentation describes interval-based purging and a separate post-test embargo in its implementation. We use those concepts here with our own explicit clock-time convention; the numerical example is not a reproduction of the library’s tests or evidence about its performance.
Deleting an event from this training fold does not mean deleting the underlying price history from every calculation. It means that its features and label cannot act as a fitted training example in this particular comparison. Another fold can give that event another role, subject to the same rules. Preserve the original data and store a mask or a list of permitted identifiers so the decision is reversible and reviewable.
The figure is also a useful debugging specification. A program that retains D has probably reduced intervals to points or tested only one endpoint. A program that retains B or F uses a different boundary convention. Neither discrepancy should be explained away by a plausible aggregate score. Resolve the interval logic first, before asking any model to fit the retained sample.
4. An embargo answers a different question
Now add a thirty-minute embargo after the latest test-label end. We define it precisely as training starts greater than 12:00 and less than or equal to 12:30. G and H are excluded by that rule. A, I and J remain. Starting from ten training candidates, purging removes five and the embargo removes two more, leaving three. The test fold still contains the same three events.
This embargo has a concrete motivation in the example. G’s trailing thirty-minute feature reads 11:45–12:15, which includes part of the protected test window. H reads 12:00–12:30 and touches its final endpoint. I reads 12:15–12:45, and J reads 12:30–13:00; neither includes an observation from 10:00–12:00. The embargo therefore excludes the two later starts whose specified feature windows still intersect that protected interval.
An embargo is a declared exclusion buffer, not an automatic proof of independence. Our choice covers a known finite feature lookback in this artificial session. It does not establish that market dependence disappears after thirty minutes, that all features have that memory, or that learning from later market regimes answers a historical forecasting question. Those are different claims requiring different checks.
Notice where the clock begins: the latest test-label end, 12:00, rather than the final test decision, 11:00. Also notice that the label publication delay is separate. The last test label becomes available at 12:10 under our assumptions, but our embargo definition is anchored to the price interval ending at 12:00. A policy anchored to availability time would produce another boundary and must say so.
Embargo alone would leave the earlier overlapping events B, C and D untouched. That is why a gap after the test block cannot replace purging. Equally, purging alone would retain G and H even though their features inspect the test window. Each operation needs a named purpose, a precise clock and a reason recorded for every affected row.
5. Lookback, horizon and publication delay are different lengths
Suppose we replace the thirty-minute trailing feature with a sixty-minute one while leaving every label unchanged. The purge decisions remain B, C, D, E and F: label geometry has not moved. However, I now reads 11:45–12:45 and J reads 12:00–13:00. Both reach the protected test interval. The old embargo is too short for the new feature construction, even though its name and configured percentage might look reassuring.
For this particular closed-window design, a sixty-minute embargo after 12:00 excludes G, H, I and J, including J at the 13:00 boundary. Only A remains after purging and the extended embargo. This is an intentionally small example, not enough data for a credible fitted-model evaluation. Its purpose is to reveal how a feature change can alter the sample that a validation procedure actually permits.
The label horizon answers how far forward an outcome looks; the lookback answers how far backward an input looks. Neither tells us when a vendor publishes the input. Imagine I additionally uses a number referring to 12:00 but first released at 12:50. I’s prediction time is 12:45. The value is unavailable even though its reference time precedes the prediction and its label interval does not overlap the test fold.
A later release cannot be repaired by a wider embargo. The offending value must be excluded, replaced according to a previously specified availability rule, or consumed only at a later valid decision. Moving I’s timestamp after seeing the issue would also change its target and its place in the split. The full example would then need recomputation rather than a cosmetic date adjustment.
For more detail on that second clock, see features and future information. Here the practical task is to preserve both checks in the split report. One column identifies interval overlap; another identifies unavailable inputs. A row can fail both, and its recorded reasons should retain that fact even if the implementation removes it only once.
6. Chronological walk-forward changes the candidate set
Return to the original thirty-minute feature. Imagine the operational question is now: what could a model fitted at 09:55 have predicted from 10:00 onward? Start by restricting training to observations available at 09:55. I and J are no longer candidates, regardless of their clean separation from the test-label interval. They occur later in the same session and could not have informed that historical fit.
Among A, B, C and D, only A has a completed, available label. Its event ends at 09:30 and its label is released at 09:40. B ends at 10:00 and would become usable at 10:10; C and D finish later still. Thus the toy walk-forward split has one training event and three test events. It demonstrates a filtering decision, not a workable sample size for the proposed model.
Chronology and non-overlap impose different restrictions. A fit using A, I and J can be described as our purged, embargoed nonchronological split. It cannot be described as the model available at 09:55. The distinction remains even if its score is lower or its training set seems more diverse. The meaning of a test comes from the procedure, not from whether its result looks conservative.
The rolling-origin account in Forecasting: Principles and Practice builds forecasts from preceding observations and advances the forecasting origin. Our event-label application adds an explicit requirement that training outcomes have matured by each fit. When a later origin admits more observations, it must check their label availability again rather than merely extending a row-index slice.
A later fold may use an earlier test event only after that event’s outcome becomes available. This can be legitimate in a declared retraining schedule. It does not change the earlier prediction retrospectively. Save each fitted version and its actual training identifiers, so the series of forecasts can be reconstructed as a sequence of decisions rather than a single model fitted using the entire history.
7. Purged cross-validation asks a narrower research question
Nonchronological purged cross-validation can compare candidate models across held-out blocks while excluding specified shared information. That can be a useful research exercise, provided the claim describes it accurately. It evaluates performance under a particular arrangement of the observed dataset, including whatever assumptions justify training on later blocks. It does not enact the arrival of information through time in the same way as the 09:55 exercise.
One reason to examine several blocks is to see whether a candidate’s behavior is concentrated in one portion of the sample. The investigator must still define what counts as comparable training conditions. Later volatility levels, different spreads or changed data collection can make a model trained on both sides of an old block a poor representation of a model that would have existed then. Removing intersections cannot remove that conceptual mismatch.
Avoid the opposite overstatement as well: the presence of time does not prove that every form of ordinary cross-validation is always invalid. Bergmeir, Hyndman and Koo discuss conditions supporting standard cross-validation for purely autoregressive models with uncorrelated errors. Their result is not a blanket justification for overlapping trading labels, delayed releases or arbitrary nonstationary features. It shows why assumptions matter more than slogans about the name of a splitter.
In a report, state which question each exercise serves. A nonchronological comparison might contribute to choosing a model specification within the development sample. A separate chronological evaluation could examine the entire selection and retraining procedure. They need not produce identical scores because they expose the procedure to different training sets and information constraints. Do not average those scores into one number without defining what the mixture is intended to estimate.
If the disagreement is large, inspect retained sample size, feature availability and calendar composition before inventing an explanation about model intelligence. In our tiny session, the first explanation is already visible: the nonchronological fit may use three events, while the 09:55 fit may use only one. Those are materially different experiments even before any coefficient is estimated.
8. A sample gap is not automatically a duration
Many tools expose a gap as an integer. The official TimeSeriesSplit documentation defines its gap as a number of samples removed from the end of training before testing. It also notes equal spacing as a condition for test folds to cover comparable durations. That parameter is useful, but it is not an event-end detector and it does not mean the same thing as our post-test clock-time embargo.
Look again at the candidate timestamps. Between 09:30 and 10:00 we have C and D, with D at 09:45; later observations use another pattern. If an event is created only when a condition fires, ten rows might represent minutes in one period and hours in another. Removing the last two training rows would eliminate C and D, but leave B touching the 10:00 boundary in the chronological candidate set.
Count units must match the exclusion rule. A time-based horizon calls for comparisons of actual times. A bar-based horizon requires a clear definition of which bars exist and whether closed sessions count. A percentage of the complete dataset is a third policy: changing the dataset length can change the embargo even if the event mechanics remain identical. Each policy may be intentional; none should be silently substituted for another.
An exact label-end filter also avoids assuming that every outcome lasts equally long. D lasts much longer than B, while G ends shortly after it starts. A fixed row gap chosen from the most common duration could miss the longest event. If a maximum horizon is used instead of realized ends, explain that this is a conservative bound and record how much additional training data it excludes.
Missing timestamps deserve explicit handling. An unknown event end is not evidence that the interval ended before the test fold. In a reviewable implementation, the observation remains ineligible until the information needed for the rule exists, or it follows a documented censoring policy. Substituting its start time would turn an unresolved outcome into an artificial zero-length label and could let it cross a boundary unnoticed.
9. Fit preprocessing after the permitted rows are known
Imagine a feature whose hypothetical values for retained training events A, I and J are 2, 4 and 6. Their mean is 4. If a centering transformation also reads a test value of 100 from T1, the mean of those four values becomes 28. The training rows have not changed, but the transformation now carries information from the protected sample. This small arithmetic example requires no fitted trading model to expose the mistake.
The correct order is to determine permitted training identifiers, estimate the transformation from those identifiers, and apply the resulting fixed transformation to the evaluation rows. The scikit-learn common pitfalls guide documents this separation for preprocessing and feature selection. A pipeline can help maintain it, but only after it receives the correct split; it cannot infer missing event intervals or publication timestamps.
Train-only means every learned preparation step. Imputation values, clipping thresholds, scaling constants and selected columns can all depend on the observations used to estimate them. A global preparation job run before cross-validation can therefore undo otherwise correct interval exclusions. Saving the fitted preparation object alongside the model makes it possible to identify which sample determined those choices.
Distinguish learning a parameter from reading permitted historical context. A fixed thirty-minute rolling mean for a test event can use earlier raw prices that would already have been observed at its decision time. It need not restart at the fold boundary and pretend the preceding market did not exist. By contrast, a normalization constant estimated using all future test rows is learned information from outside the training set. The two operations have different information requirements.
For stateful transformations, write down how state is initialized and updated during testing. A declared online update using newly arrived, unlabeled observations can be part of an operational procedure. A retrospective pass over the completed test period cannot be relabeled as the same procedure. The rule should describe the state that existed before each prediction, especially when two test events occur close together.
10. Repeat the separation inside model selection
An outer test block should evaluate the procedure selected within the outer training sample. If that procedure chooses among feature sets or model settings, its inner validation splits need their own interval checks. A row permitted for outer training may overlap an inner validation label. Outer purging is relative to the outer test block; it is not a permanent certificate that every retained pair can safely be separated later.
The official nested cross-validation example distinguishes inner selection from outer evaluation. Its example concerns a different dataset, so its splitting code should not be copied as an event-time solution. The relevant principle here is the separation of decisions: the outer evaluation does not choose the settings whose procedure it is measuring.
Each inner split gets a fresh preprocessing fit. First construct its eligible training set within the outer training pool; then fit the transformations and candidate model there. Score the candidate on that inner validation block. After the selection rule chooses a setting, refit the complete preparation and model on the eligible outer training set, and apply the fixed result to the outer test block.
Our thirteen-event session is too small to demonstrate meaningful nested selection after the exclusions. The figure explains responsibilities, not an experiment allegedly performed on those three surviving rows. A real study needs enough eligible observations in every inner split to support its chosen procedure. If a fold cannot train the model or lacks a required target class, record the limitation rather than quietly allowing excluded events back in.
Selection also includes choices about validation itself. Choosing an embargo because it produces the most appealing outer score uses that outer block to design the procedure. Prefer a rule justified by known feature construction and availability. If several defensible rules are investigated, identify that investigation as development and retain the comparison history, including cases with an inconveniently small training sample.
11. Reconcile the sample before interpreting a score
The original nonchronological exercise starts with thirteen events: three test events and ten training candidates. Five candidates are purged and two additional candidates are embargoed, leaving three retained training events. Expressed relative to training candidates, half are purged, one fifth are removed by the additional embargo, and three tenths remain. Those fractions are bookkeeping consequences of this invented table, not recommended exclusion rates.
Report removed identifiers as well as counts. Matching totals alone can conceal an exchange: a broken implementation could wrongly retain B and wrongly remove I, still reporting three retained rows. The expected retained set is exactly A, I and J under the original assumptions. A reviewer should be able to match each exclusion reason to the interval table without reverse engineering a model’s score.
Keep the categories disjoint when presenting a simple accounting chart. In our convention, report overlap exclusions first, then additional embargo exclusions among the survivors. Internally, retaining multiple reasons is useful, but adding overlapping reason counts can exceed the number of candidates. State whether a reported figure counts unique observations, exclusion flags or repeated appearances across folds.
Purging can alter the composition of the remaining training sample. Long-lived events can be more likely to intersect a boundary than short-lived ones. Boundaries placed around a busy session can remove many more candidates than those placed in a quiet period. Examine duration and calendar coverage among retained and removed events. A split can satisfy its mechanical rule while leaving a training population different from the one the research question intended.
Changing the horizon from one candidate model to another compounds that issue. If each model is evaluated on a different set of valid test events, a score difference can reflect the sample as well as the model. Keep the evaluation population aligned where the question requires it, or report the changed populations explicitly. Never treat equal fold numbers as proof that two evaluations used equivalent information.
12. A clean split still contains dependent test events
T1, T2 and T3 overlap one another inside the test fold. Removing their overlap with training does not separate them from each other. A common price movement can influence several test labels, so three recorded answers need not provide the information of three independent repetitions. The same issue appears when many instruments react to one event or when several labels represent versions of one underlying trade decision.
To keep the distinction concrete, suppose a fixed hypothetical model assigns positive-outcome probabilities of 0.6, 0.4 and 0.7 to T1, T2 and T3. Suppose their hypothetical binary outcomes are 1, 0 and 1. The mean squared probability error, or Brier score, is the average of 0.16, 0.16 and 0.09: approximately 0.1367. A constant probability of 0.5 gives 0.25 on these same three outcomes.
Those are exact calculations conditional on invented inputs. They are neither observed historical evidence nor a forecast of future performance. Three overlapping outcomes cannot establish predictive skill. Even a perfectly implemented exclusion mask would not justify a confidence interval based on three independent events without an additional dependence argument. Nor would this probability score establish trade profitability, execution feasibility or a suitable position size.
Purging addresses a relation between training and testing; uncertainty also depends on relations within testing. When aggregating a larger study, retain the dates and event identifiers behind its predictions. That makes it possible to examine clustering, repeated outcomes and shared market exposure before choosing an uncertainty calculation. A single average discards exactly the information needed for those checks.
If the research objective is an executable portfolio, overlapping predictions also need an execution policy. T2 might arrive while a position associated with T1 is still open. Whether the system adds, replaces or ignores exposure affects the trading record. Interval validation does not supply that policy. Keep label-level predictive evaluation distinct from the subsequent simulation that maps simultaneous signals into positions.
13. Test the boundary rules with deliberately awkward cases
Before running a large search, construct tiny interval cases with outcomes known by inspection. Our B and F test endpoint contact; D tests full containment; A tests separation before the fold; G tests separation after it. Add identical training and test intervals and an event whose start equals its end. Under the stated closed convention, identical intervals overlap and a point interval overlaps any interval containing that point.
Assertions should name the invariant. After purging, no retained training-label interval may intersect any test-label interval. After our additional embargo, no retained training start may lie in the declared buffer. For chronological fitting, every retained training label must be available by the fit time. These are distinct assertions; passing one does not imply the others passed.
Use a slow pairwise calculation as a reference for a faster splitter on small synthetic tables. Sorting, merging test intervals and searching boundaries can improve speed, but each optimization can introduce an endpoint mistake or confuse a position in an array with an event identifier. The reference calculation should operate directly on starts and ends, without sharing the optimized implementation’s shortcuts.
Then perturb the example in ways that should have predictable effects. Move B’s end from 10:00 to 09:59 while holding every other field and policy fixed: B should stop failing label-overlap purging. Its label would still be unavailable at 09:55 because of the ten-minute release delay. This single-minute change illustrates why an interval test and a chronological eligibility test require separate expected answers.
Also test shuffled storage order, duplicate timestamps and multiple instruments. Shuffling storage should not change identifier-level membership after sorting the event table correctly. Equal timestamps should retain separate identifiers. Group rules must reflect the research question: shared market inputs or a common target event can connect instruments even when instrument names differ. A timestamp comparison is only as meaningful as the information sets it represents.
14. Keep the conclusion as precise as the exclusions
A useful review record begins with the evaluation question and the meaning of each clock. It identifies the target construction, endpoint convention, test intervals, training candidates, purge mask, embargo anchor and unit, and input availability assumptions. It also preserves the preparation fit and the selection history. These details let another person reproduce why A was admitted and why B was not, without needing access to a proprietary trading rule.
For our original session, the justified conclusion is narrow: the closed-interval purge removes B, C, D, E and F; the stated thirty-minute embargo additionally removes G and H; A, I and J remain for the nonchronological exercise. For a model fitted at 09:55, only A is available. Increasing feature memory to sixty minutes also leaves only A under the corresponding extended embargo. None of these statements establishes model quality.
The distinction becomes valuable when a backtest looks unexpectedly strong. Ask which future observations entered its training labels, which test-period observations entered later training features, and which values were genuinely available at each fit. Each answer directs a specific repair. Adding a generic gap without identifying the channel can consume data while leaving the original problem in place.
The deliverable is an auditable information boundary. Once it is correct, a researcher can investigate forecasting accuracy, uncertainty and execution with a clearer understanding of the experiment. If too little training data remains, that is a result about the proposed design. It may motivate a different event definition, more observations or a simpler model; it does not authorize relaxing the boundary after seeing the score.
For the operational sequence of fitting and predicting, continue with walk-forward retraining. If you want to examine the material available in the TradeAndRoll demo, bring this interval table as a review aid: first establish what the supplied records can verify, then keep any unobservable timing assumptions explicit.
Sources
- OpenQuant: cross-validation. Implementation documentation for interval purging and post-test embargo; not evidence of trading performance.
- scikit-learn: TimeSeriesSplit. Sample-count gap and time-order semantics.
- Hyndman and Athanasopoulos: forecasting toolbox. Section 5.10 explains rolling forecasting origins.
- Bergmeir, Hyndman and Koo: validity of cross-validation. Conditions for autoregressive prediction; not a general exemption from interval checks.
- scikit-learn: common pitfalls. Training-only estimation of preprocessing and feature selection.
- scikit-learn: nested versus non-nested cross-validation. Separation of parameter selection from outer evaluation.



