Market Microstructure Model - Central Limit Order Book Simulation
GitHubOverview
C++ limit order book simulation modeling execution, queue priority, and liquidity dynamics in a price-time priority exchange environment.
Built to study how order flow and queue position determine execution outcomes in fast-moving markets.
Trading Problem
Execution in order-driven markets is determined by microstructure, not price alone.
Queue position, order arrival dynamics, and liquidity depth determine execution outcomes.
Core Idea
A price-time priority limit order book simulator is built to model execution under stochastic order flow.
The system focuses on how execution uncertainty emerges from matching mechanics and queue priority.
Trading Mapping
This models:
- Passive execution risk under queue position uncertainty
- Market vs limit order interaction in liquidity consumption
- Queue dynamics in market making environments
- Path-dependent execution outcomes under stochastic order arrival
Key Mechanisms
- Price-time priority (FIFO matching)
- Market / limit / cancel order flow
- Order book liquidity depletion and replenishment dynamics
- Partial fills and queue-based execution
Key Insights
- Queue position is a primary driver of execution probability in passive order flow
- Displayed liquidity is not equivalent to executable liquidity under fast order flow
- Execution outcomes are path-dependent and sensitive to order arrival sequence
- Liquidity consumption dynamics determine short-horizon fill uncertainty
Core Takeaway
Execution outcomes emerge from microstructure mechanics - specifically queue priority and stochastic liquidity interaction - rather than price levels alone.
Market Microstructure & Execution Visualizations
Benchmarks comparing execution throughput, matching latency, and order book query performance across C++ vs Python implementations.
High-Throughput Price-Time Priority Matching Engine (C++ Implementation)
C++ limit order book processing 99,999 order events in ~0.67s, demonstrating low-latency execution, queue-based matching, and high-frequency order flow processing.
Reference Order Book Engine for Logic Validation (Python Baseline)
Python implementation processing identical order flow (~6s), used as correctness benchmark for execution logic, matching consistency, and state parity validation.
Low-Latency Order Book State Query for Liquidity and Depth Inspection
Efficient retrieval of live and historical order book states enabling real-time liquidity inference and execution timing analysis.
Reconstructed Order Book Depth Snapshot for Liquidity Structure Analysis
Full market depth reconstruction illustrating resting liquidity distribution and executable order book structure at a given timestamp.
Order Book Snapshot (Add + Cancel functionality)
Order addition / cancellation behavior demonstrating liquidity removal, depth reshaping, and microstructure-driven book evolution.