Feature Engineering and Data Leakage in Trading Models
Build time-aware market features and avoid information leakage that can make a trading model look unrealistically accurate.

Every feature needs a timestamp story
Feature engineering converts raw data into values a model can use. In trading research, each feature needs a clear answer to one question: would this value actually have been available at the time the model makes its prediction? A moving average computed from past completed bars may be available after the bar closes; a daily high that includes the rest of the day is not available at the morning decision point. Store timestamps, exchange sessions, time zones and bar completion rules. Document the source and transformation for every field. This simple data dictionary helps reviewers understand whether the feature reflects information known then or information reconstructed later.
Recognize common forms of leakage
Leakage happens when training information includes data that would not be available in a real decision. Examples include using future prices in a rolling statistic, normalizing all observations before splitting by time, joining labels onto the wrong date, using a revised company value before its publication, or calculating a feature with a window that crosses a validation boundary. Leakage can also occur when duplicate or near-duplicate observations appear across training and test sets. The model may then memorize details that will not be available in future periods. Review the full data pipeline, not just the model fit, because leakage often enters during preprocessing or data joins.
Use point-in-time construction
Build each observation as if it were created at its historical decision time. Use only records whose publication or availability timestamp precedes that point, apply transformations using training data where appropriate, and preserve chronological ordering. For rolling features, verify window boundaries and whether the current bar is complete. Use time-based splits and rerun the pipeline separately within each training fold when preprocessing learns parameters such as scaling or imputation values. Write small manual examples for a few dates and confirm every input matches the information that would have been known. These checks are often more revealing than another round of model tuning.
Inspect suspiciously good results
A sudden jump in accuracy, stable profits across every period or near-perfect classification should trigger an audit before celebration. Compare against a simple baseline, check target alignment, inspect the largest feature contributions and verify that removing questionable fields does not collapse the result. Evaluate on future periods that were not used to choose features or parameters. Include realistic trading costs before interpreting a predictive score as an economic result. Maintain a record of each data and model change. Leakage checks improve research credibility, but clean validation still cannot guarantee future performance because markets and data relationships can change.