Skip to content
All library documents

High-Frequency Backtesting with Latency and Queue Position

Article Stratmill research code

Summary

The README describes a market replay framework for researching high-frequency trading and market-making strategies. It reconstructs order books from detailed market data and simulates order and feed latency, queue position, and fills. Its tick-by-tick engine supports multiple assets and exchanges, with custom latency and fill models. A sample market-making loop illustrates using a forecast and inventory risk to set quotes, managing existing orders, and respecting a position limit.

The document argues that a useful backtest should reproduce live execution closely enough to assess whether small trading edges are real. It proposes comparing a backtest against actual results for the same period before moving on to optimization or overfitting analysis. This is guidance about validation rather than reported evidence: the README provides no empirical comparison or performance results. Replay accuracy also depends on the quality of the market data and simulation assumptions, and the document acknowledges that full realism can be costly or impractical.

Key ideas

  • The framework replays detailed order book and trade data to simulate high-frequency trading.
  • Latency and queue position are modeled because they affect whether and when orders fill.
  • Market-making quotes can be adjusted using a price forecast and inventory risk.
  • Backtests should be compared with live results over the same period before strategy optimization.
  • Simulation fidelity depends on data and assumptions, and greater realism can require more time.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.