Choose the primitive
For a reproducible backtest window, Prepare data for a reproducible backtest combines these steps.
Source metadata
Record these for every replay or reconstruction run:- venue and market type, and symbol
- route, channel, or export schema key
- start and end time
- cursor or replay sequence
- snapshot source
- diff or event source
- gap, reconnect, and retry events
- data-quality result
meta.request_idwhere REST is involved
State boundaries
Replay sends ordered historical events. Reconstruction turns a baseline plus ordered changes into local state. Keep the two separate in code and output labels. A replay file can be correct while a reconstruction is unsafe, if the client applied messages out of order, ignored a gap, or rebuilt from the wrong snapshot.
State labels matter to downstream users. A chart can show a partial replay window, but a trading model or backtest should not treat a partial reconstruction as clean input. Handle a gap as described in Data quality.
When not to use replay
Do not use replay when a REST snapshot answers the question. Replay is heavier and stricter, because sequence mistakes can silently corrupt local state. Use it when timing, causality, diffs, or historical event order are part of the requirement. If the same workflow later moves from WebSocket replay to exported files, keep the replay metadata with the file output so the rebuild can be explained later.Minimal run manifest
Which clocks and boundaries belong in a backtest?
Keep the checkpoint’s state boundary separate from the time your application received it. For Hyperliquid L4,last_block_number anchors the checkpoint, and subsequent diffs are applied in block/sequence order. A timestamp alone does not order every event or establish that two files share the same boundary.
For Lighter tick history, retain the checkpoint and follow the returned continuation cursor without resetting it or replacing it with a timestamp-only query. Sequence values order deltas but are not a consecutive counter within one market.
Record the requested UTC bounds, source, baseline, cursors and gap state with the output. If a strategy depends on when information first became observable, record that observation time separately: a market-event timestamp is not an available_at record. replay_completed marks the end of the returned stream, not a substitute for the baseline and gap checks.