Market Microstructure Markovian Queue Dynamics Cont, Stoikov & Talreja (2010)

Cont-Stoikov (2010) Order Book Lab

Simulate Rama Cont, Sasha Stoikov, and Rishi Talreja's (2010) stochastic model for limit order book dynamics. Model Markovian queue depletion, 2D first-passage price move absorption probabilities $p_1(x, y)$, and equilibrium depth distributions.

Theoretical Foundations: Markovian Limit Order Book Queues & First Passage Probabilities
1. Birth-Death Queue Transitions & Depletion Time

At each price queue, limit orders arrive at rate $\lambda$, market orders execute at rate $\mu$, and resting orders cancel at state-dependent rate $\theta q$. Expected queue depletion time $E[\tau \mid q_0]$ satisfies:

$$(\lambda + \mu + \theta k) T(k) = 1 + \lambda T(k+1) + (\mu + \theta k) T(k-1), \quad T(0) = 0$$

Because cancellation intensity $\theta q$ scales with depth, large queues erode via cancellation rather than market orders, driving sub-linear depletion time growth.

2. Price Move Absorption Probability $p_1(x, y)$

Given bid depth $x$ and ask depth $y$, the probability that the next mid-price move is an increase (+1 tick) satisfies the 2D discrete harmonic equation:

$$R(x, y) p_1(x, y) = \lambda_b p_1(x+1, y) + (\mu_b + \theta_b x) p_1(x-1, y) + \lambda_a p_1(x, y+1) + (\mu_a + \theta_a y) p_1(x, y-1)$$

Boundary conditions: $p_1(x, 0) = 1$ and $p_1(0, y) = 0$. When $\lambda = \theta = 0$, this yields the exact Order Book Imbalance (OBI) baseline $p_1(x, y) = \frac{x}{x + y}$.

Order Book Parameters

Large-Cap Equity (Liquid / Heavy Queues): High limit order replenishment (lambda = 12.0/s) and balanced market order flow (mu = 8.0/s), typical of SPY or Apple order books.

Price Up Prob $p_1(x, y)$ 50.0% Balanced Liquidity
Order Book Imbalance 0.0% $(x - y) / (x + y)$
Bid Depletion Time -- Expected: $E[\tau_b]$
Ask Depletion Time -- Expected: $E[\tau_a]$
Equilibrium Depth: --
Depletion Ratio: --
Cancel Share: --
Quoted Spread: 1 tick
Dual 5×5 Microstructure Sensitivity Grids
Sensitivity Grid 1: Bid Depth $x$ vs Ask Depth $y$ → Price Increase Probability $p_1(x, y)$

Shows the transition surface of the probability of an immediate upward mid-price jump across queue combinations:

Sensitivity Grid 2: Market Order Rate $\mu$ vs Cancellation $\theta$ → Depletion Time ($q_0 = 10$)

Demonstrates queue resilience and expected seconds to depletion under varying execution and cancellation intensities:

Market Microstructure Mastery: Cont, Stoikov & Talreja (2010)
Related Order Book & Market Microstructure Simulators
Guéant-Tapia-Manziadi Lab

Closed-form market making, Cole-Hopf HJB linearization, tridiagonal matrix exponentials, and exact inventory bounds.

Explore Guéant Lab
Cartea-Jaimungal Lab

Optimal high-frequency quoting with short-term predictive alpha drift signals, OU processes, and inventory risk control.

Explore Cartea Lab
Order Flow Imbalance Lab

Cont-Kukanov-Stoikov (2014) limit order book event decomposition, multi-level OFI regressions, and market depth resilience.

Explore OFI Lab
Cont-de Larrard (2013) Lab

Heavy-traffic diffusion limit, conformal harmonic exit probabilities $\frac{2}{\pi}\arctan(q_b / q_a)$, and micro-volatility $\sigma^2 = \frac{\pi\mu\delta^2}{4D^2}$.

Explore Diffusion Lab
Frequently Asked Questions: Cont-Stoikov-Talreja (2010) Order Book Model

The Cont, Stoikov, and Talreja (2010) model is a foundational continuous-time Markov chain framework for high-frequency limit order books (LOBs). It treats price queue depths as interacting birth-death processes driven by limit order arrivals, market order executions, and state-dependent order cancellations, providing analytical formulas for queue depletion times and price move probabilities.

The model formulates the price move as a 2D first-passage absorption problem. Given current bid queue depth $x$ and ask queue depth $y$, the probability $p_1(x, y)$ that the ask queue depletes before the bid queue satisfies a discrete harmonic boundary value problem. In the benchmark without cancellations, it reduces to the order book imbalance ratio $p_1(x, y) = \frac{x}{x + y}$.

The expected depletion time $E[\tau \mid q_0]$ of a queue of size $q_0$ is solved analytically from the birth-death generator with birth rate $\lambda$ and death rate $\mu + \theta q$. Because cancellations grow linearly with queue size ($\theta q$), expected depletion times grow sub-linearly with initial depth, demonstrating that large queues erode primarily through cancellations rather than market orders.

Limit orders arrive at price level $i$ with power-law intensity $\lambda(i) = \lambda_0 / i^\alpha$, replenishing the book. Market orders arrive at the best bid and ask with rate $\mu$, consuming liquidity. Cancellations occur at rate $\theta q$, removing resting orders proportionally to queue size. The balance between these three Poisson streams dictates order book resilience and spread dynamics.

Under detailed balance, the equilibrium probability of finding $k$ contracts in a queue is given by $P(Q = k) = P(0) \prod_{j=1}^k \frac{\lambda}{\mu + \theta j}$. This produces a generalized negative binomial / Poisson-Dirichlet distribution whose mean depth $E[Q]$ reflects the steady-state liquidity profile of the market.