Simulation Environments for Strategy Testing
Simulating a strategy against a replayed order book with a real matching engine tests things a price-only backtest cannot, including a strategy's own market impact.
A simulation environment replays historical market data through a matching engine that behaves like a real exchange, filling a strategy's orders against a reconstructed order book rather than against a simplified series of trade prices, and that distinction is what separates simulation from an ordinary backtest. A backtest can tell a strategy whether its signal would have been right; a simulation can tell it whether the order it would have sent would actually have filled, and at what price, given the queue it would have joined.
A price-based backtest checks a signal against a series of closing or trade prices and assumes the strategy's own orders had no effect on those prices, which is a reasonable simplification for a strategy trading a small size in a deep market and a materially wrong one for anything trading near the top of the book or in size. The mechanics of that gap, and the specific biases it introduces, are covered in the guide to backtesting and bias prevention.
Simulation closes that gap by reconstructing the full order book at every point in time from historical data rather than the trade prices alone, which lets a strategy's simulated orders queue, partially fill, or get skipped over exactly as a real order would.
The matching engine inside a simulation environment applies the same price-time priority rules the real exchange uses, so a simulated limit order joins the back of the queue at its price level and only fills once every order ahead of it in time has either filled or been cancelled. Building this correctly requires historical data granular enough to reconstruct queue position, which is a materially heavier data requirement than the trade-and-quote data a simple backtest needs.
Getting queue position wrong in either direction biases the result: assuming an order fills immediately overstates a passive strategy's edge, while assuming it never fills understates it, and both errors compound across a full trading day of simulated quoting.