Generating Synthetic Order Latency from Market Feed Delays
Summary
This example generates order-latency records for a crypto trading backtest from historical feed data. It first keeps events that contain both exchange and local timestamps, then aggregates to one record per second using the last timestamps in each interval. Their difference estimates feed latency. Configurable multipliers and offsets convert that estimate into order-entry and order-response delays, producing request, exchange, and response timestamps for each record.
The script processes daily files for a chosen symbol and date range, saves compressed latency data, and catches errors on a per-day basis. Its main caveat is that feed latency is only a proxy: the comments explicitly say order latency can differ substantially and recommend actual historical order-latency data for each trading pair when available. The example therefore illustrates a simulation technique, not evidence that its chosen multipliers reproduce real execution conditions. Backtest conclusions that depend on fill timing may be sensitive to this approximation.
Key ideas
- The example estimates feed delay from local and exchange event timestamps.
- It scales feed delay with separate multipliers and offsets for order entry and response.
- Latency records are built from the last qualifying event timestamps in each one-second interval.
- Actual historical order latency is preferable because feed and order delays may differ substantially.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.