Trading Dev AcademyFree quant education

Free lesson · Point-in-time data

Purging labels that cross a test boundary

Open interactive lessonPractice calculationsExplore labs

Start with the idea

A training label can contain future test-period outcomes even when its feature timestamp is earlier.

Symbols, units & horizon
  • e_i: final observation timestamp included in training label i
  • b: first timestamp included in test outcomes
  • strict inequality uses closed label intervals
  • feature timestamp precedes label end
  • all times share a clock

When and why to use this

Build chronological splits for return forecasts and event-driven strategies.

A training label can contain future test-period outcomes even when its feature timestamp is earlier.

A five-day return label matures five days after its decision. If the test begins tomorrow, that unfinished label includes test-period prices. Exclude it from training at the boundary. Multi-asset labels and event windows can overlap in more complex ways.

Fit normalization and model selection within permitted training information as well. Purging outcome intervals does not cure feature leakage, test reuse or dependence between retained observations.

keep training label i⟺ei<b
Closed-interval label-overlap convention

Purging labels that cross a test boundary

  1. For each label record both start and final included outcome time.
  2. Compare the final included time with the first test timestamp.
  3. Retain only labels ending strictly earlier under the declared closed-interval convention.
Work it by hand

Test begins at day 10. Labels ending on days 8, 10 and 12 produce keep flags [true,false,false]. A label ending exactly at 10 overlaps.

Apply it in a strategy

  • Freeze inputs at the stated decision time and record their units.
  • Build chronological splits for return forecasts and event-driven strategies.
  • Recompute the example, then change the material assumption and explain the difference.

Research deliverable

Purging labels that cross a test boundary: produce the worked calculation, a timestamped input record and a written decision addressing this limitation: Purging is one leakage control, not a guarantee of independent samples or honest model selection.

These are synthetic mechanics examples, not historical performance or paper replications. Module evidence and research boundaries record the 12 September 2026 review.

Python implementation

Self-contained teaching example. Python 3.10+; dependencies and input conventions are shown in the code and notation. Run in your own Python environment.

# Python 3.10+; standard library and NumPy only.
# Synthetic teaching inputs; conventions and units are defined in the notation above.
def purge_before_test(label_ends,test_start):
    return [end<test_start for end in label_ends]

assert purge_before_test([8,10,12],10)==[True,False,False]
print(purge_before_test([8,10,12],10))

Continue learning

Data: Availability, Revisions & Reproducible Research — all lessons
  1. Four clocks for one observation
  2. An as-of join that never selects the future
  3. First prints and revisions can reverse a signal
  4. Reconcile splits and cash distributions
  5. Universe membership and disappearing assets
  6. Coverage, missingness and stale values
  7. Purging labels that cross a test boundary
  8. Reproducible snapshots and discrepancy ledgers

Quantitative finance and development glossary · Python resources and libraries · Research sources and limitations