Backtest Event Ordering: Test Gaps Between Bars
Backtest event ordering: Specify when signals become available and use a gapped fixture to expose ambiguous timing.
Put this into practice with a watchlist
Build a watchlist, then review each signal’s entry, stop, target, and reasoning. Broker access is optional.
Public subscriptions are paper-only; separately approved private beta accounts may submit live broker orders.
Backtest event ordering: Specify when signals become available and use a gapped fixture to expose ambiguous timing.
The data-accuracy discussion described uncertainty in an LLM-built futures backtester, particularly around minute-bar gaps and timestamps. Accessible comments proposed integrity checks and independent calculations. No reviewed code established the engine as correct, so a small counterexample is more useful than assurance.
The source discussion is a starting question, not verified strategy evidence. Accessible comments were reviewed incompletely; some replies remained unavailable. Author results are unverified. The exercise below is original educational reasoning with hypothetical inputs, not a reproduction of those results.
Backtest event ordering: bar-gap engine test: make a tiny tape
Create a hand-written sequence with five bars, an overnight boundary and one missing interval. Store timestamps with a stated timezone. Choose prices that visibly differ between the previous close and the next open. This makes an accidental substitution observable without requiring a large historical dataset or an expensive provider subscription.
Write expected behavior before running the engine. Specify when the signal becomes available, the first eligible order time, how a missing bar is handled and which price marks an open position. Do not silently fill a missing interval with a tradable price. A forward-filled value may be useful for some calculations while remaining unavailable as an execution opportunity.
Worked example: the next open is not the last close
Imagine a signal calculated after a close of 100. The next session opens at 108 and later closes at 106. A rule that buys only after the signal is available cannot claim an entry at 100 merely because that was the latest stored value. For one share, buying at 108 and marking at 106 produces a loss of 2 before costs. These are synthetic values, not market observations.
Change the next open to 92 while keeping the earlier bars identical. Decisions made before that open should remain identical unless the documented rule legitimately waits for it. This is a simple truncation-invariance test: future edits must not change already completed historical decisions.
Put the setup on a watchlist first
Use the rules in this guide to evaluate a signal’s entry, stop, target, and reasoning before deciding what, if anything, to do.
Public subscriptions are paper-only; separately approved private beta accounts may submit live broker orders.
Test information time separately from row time
A row labeled with a session date can contain a field published later. Add an availability timestamp to a synthetic feature and prevent the decision function from reading it early. Shift that availability time while leaving the value unchanged. Only decisions after the new availability boundary should be able to respond.
For a rolling indicator, calculate the expected value by hand on the permitted rows. Repeat with a duplicate timestamp and an out-of-order bar. The engine should reject or explicitly normalize those inputs according to a stated policy. Quietly sorting and deduplicating can conceal an upstream feed issue that deserves a report.
Keep instrument conventions visible
Futures roll treatment and equity corporate actions need different explanations. A raw-versus-adjusted slogan does not specify contract eligibility, settlement, split handling or executable prices. Record the convention used in the small tape, then preserve it in larger runs.
A passing test establishes one defined behavior. Expand the tape with a halt, session change or missing symbol only when that case matters to the intended model. Independent expected calculations are the evidence; the engine repeating its own answer is not.
Reference and first useful step
TimeSeriesSplit provides chronological train/test indices and an optional gap. TimeSeriesSplit documentation.
Open Advisory Research to explore a local sample report and inspect its assumptions before comparing your own saved evidence. Choose a synthetic sample before importing offline JSON. Keep outputs advisory; this exercise does not place trades. For background, read backtesting fundamentals and paper trading.
Continue the research
Earnings Backtests: Use an As-Of Event Calendar and Backtest P&L Reconciliation: Audit Matched Trades develop adjacent checks. Use a small synthetic fixture first; these educational diagnostics do not validate a trading edge or change account settings.
Frequently Asked Questions
Should a missing bar be treated as a fill?
No. Missing observations do not establish executable liquidity.
What is truncation invariance?
Future changes should not alter decisions already made before the cutoff.
Can an LLM assurance validate timestamp logic?
No. Use independent expected calculations and explicit availability tests.
Why store a timezone?
It makes session boundaries and event ordering explicit instead of relying on ambiguous clock labels.
What should happen to duplicate bars?
Reject or normalize them under a documented policy and report the integrity issue.
Read next
Keep learning with a related guide before putting an idea on your watchlist.
How to Backtest Trading Strategies: A Practical Guide for 2026
Learn how to backtest trading strategies properly -- avoid common pitfalls like overfitting, survivorship bias, and look-ahead bias.
Paper Trading App Workflow: Review Stock Signals
Use a paper trading app workflow to review stock signals, record entry, stop, target, and rationale, then revisit decisions without a broker connection.
Earnings Backtests: Use an As-Of Event Calendar
Earnings backtests: Freeze calendar availability at the decision time before testing whether earnings features add information.
Backtest P&L Reconciliation: Audit Matched Trades
Backtest P&L reconciliation: Match trade quantities and prices before assigning unexplained P&L to an execution cause.
Try AI signals on your watchlist
Send yourself a signal preview, then add tickers to see ranked entries, exits, and risk notes in Tradewink.
Key Terms
Sources cited in this guide
- source discussion (reddit.com)
- TimeSeriesSplit documentation (scikit-learn.org)
Tradewink builds explainable market research for self-directed traders. Build a watchlist, inspect signal reasoning and risk context, and paper-track ideas before you decide. Public subscriptions are paper-only; separately approved private beta accounts may submit live broker orders.
How this guide is reviewed
Tradewink reviews educational content against its documented market-data sources, risk controls, and product methodology. See our data sources and evaluation methodology for the evidence and limitations behind the platform, and our editorial standards for how guides are sourced, dated, and corrected.