Define the decision time, execution time and target horizon before constructing features. Join each feature using when it became available, fit preprocessing and models only on eligible history, and evaluate forward in time. Audit a few individual rows against the raw data timestamps. A good feature must be reproducible by the system operating at the stated decision time.
Give every training row three timestamps
Define a row at the close of session . If the strategy enters at open and exits at open , its target return is
Feature values can use the close at if your live system waits for it and executes the next day. For periodic data, use a point-in-time join keyed by the release timestamp and, where possible, the vintage actually available. Build the cross-sectional universe as it existed on the decision date, and keep assets with valid past observations even if they delisted later.
A company reports quarterly revenue at 17:00 on Friday, after the 16:00 decision. Its fiscal quarter ended in September. A join on the quarter end makes the figure appear during September, and a join on a date stripped of its time makes it appear in Friday's decision. A timestamped join makes it available for the next eligible decision. If your data provider delivers it at 08:15 on Monday and you use end-of-day decisions, Monday's close is the first eligible row.
For your test, pick this release and manually verify the feature value on Thursday, Friday and Monday. Run a second assertion that changes Monday's release value and confirms Friday's feature vector stays identical. This catches regressions in an otherwise plausible merge.
A practical leakage test is to rebuild an old feature row after adding data that arrived later. The row should be identical. Apply that test to revisions as well as first releases. If a vendor replaces the original value with a restated value, the latest file alone cannot recreate what the model saw. Keep a release or ingestion timestamp and historical versions for information that can change. Use the same timestamp conventions at feature generation, fitting, and historical execution.
References and next steps
- Scikit-learn, common pitfalls demonstrates leakage from preprocessing and how pipelines keep fitting inside training.
- How to Audit a Backtest for Look-Ahead and Survivorship Bias