Skip to content
All library documents

How a No-Partial-Fill Exchange Simulates Limit Order Fills

Code Stratmill research code

Summary

This document describes a backtest exchange model for limit orders that treats every execution as a full fill. It supports good-till-canceled and post-only orders, tracks orders by price level, and uses a queue model to estimate whether trades at an order’s price have reached its position. Orders can also fill when the best opposing quote moves through their price.

Marketable orders are filled in full at the best price, regardless of displayed quantity. The document explicitly warns that this can make simulations unrealistic for large orders. The code outlines event handling for trades, depth changes, order acknowledgments, cancellations, and modifications, but the excerpt is incomplete and does not report validation results or compare simulated fills with live execution. Its assumptions therefore define a simplified fill model rather than evidence that the modeled outcomes match actual markets.

Key ideas

  • The exchange model fills an order in full rather than simulating partial executions.
  • A queue model updates order position when trades occur at the order’s price.
  • A move in the best opposing quote can trigger a maker fill for orders crossed by that quote.
  • Marketable orders fill fully at the best price, regardless of available displayed quantity.
  • The model supports limit orders with good-till-canceled and post-only time-in-force settings.

Tags

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