Introduction¶
The limit order book (LOB) is the core market mechanism in most modern electronic equity and derivatives markets. Understanding its statistical properties — how orders arrive, how they interact with existing quotes, and how prices emerge — is essential for designing execution algorithms, calibrating market impact models, and building realistic simulations for strategy backtesting.
This chapter develops models for the LOB from the ground up. We begin with models for order arrival in Section Models for order arrival: the stochastic processes (Poisson, Hawkes) that govern when and how orders reach the market. Section Market impact models covers market impact models that quantify how individual trades move prices. Section Volume prediction models develops volume prediction models for anticipating the participation rate of the market at different times of day. Section LOB features catalogues the standard LOB features — order imbalance, spread, depth ratios — used throughout the execution and market-making chapters. Section Probability of filling a limit order derives the probability of filling a limit order, the key stochastic building block for execution tactic design. Section Short-term price prediction covers short-term price prediction from LOB data, and Section Information asymmetry discusses information asymmetry models that link order flow to adverse selection. The chapter closes with LOB simulation in Section Simulation of LOBs, covering both probabilistic generative models and the agent-based model of McGroarty et al. McGroarty et al., 2019.
Models for order arrival¶
Order arrival is the fundamental stochastic process driving LOB dynamics. Three aspects need to be modelled jointly: when orders arrive, what type of order arrives (limit, market, or cancel), and the parameters each order carries (side, size, and price level).
Poisson process¶
The simplest model treats orders as a homogeneous Poisson process with constant intensity . Under this model, inter-arrival times are exponentially distributed with mean , and the number of orders in any window of length follows . Despite its simplicity, the Poisson model forms the analytical backbone of many LOB models — including the fill-probability model in Section Probability of filling a limit order and the Avellaneda-Stoikov market-making model in Chapter Optimal Market Making.
A direct empirical observation rules out constant intensity: trading activity follows a strong intraday pattern, peaking at the open and close and troughing at midday — the well-known U-shaped volume curve discussed in Section Volume prediction models. The natural extension replaces with a deterministic time-varying intensity , producing a non-homogeneous Poisson process. Conditional on , the process retains independent increments; only the marginal rates change.
Hawkes self-exciting process¶
A more fundamental departure from the Poisson model is the Hawkes process Hawkes, 1971, which adds a self-excitation mechanism: each arriving order temporarily increases the probability that further orders arrive. The intensity at time is
where is the baseline (background) intensity, is the jump in intensity triggered by each event, and is the decay rate. After an order arrives at time , intensity jumps by and then decays exponentially back toward the baseline. The process is stationary when , which imposes a bound on the strength of self-excitation. The stationary mean intensity is and the variance of the event count over a window is asymptotically , the Poisson variance inflated by the self-excitation factor.
The Hawkes process captures two key empirical regularities of high-frequency order flow: clustering (orders arrive in bursts) and persistence (autocorrelation in the order-sign series persists for hundreds of events). Bacry, Mastromatteo, and Muzy Bacry et al., 2015 showed that Hawkes processes provide an excellent fit to high-frequency order flow in equity markets, reproducing both the inter-arrival distribution and the long-memory autocorrelation structure.
Multivariate Hawkes models extend the framework to interacting event streams — buy limit orders, sell limit orders, buy market orders, sell market orders, and cancels — each with its own baseline intensity. The cross-excitation between streams is captured by a kernel matrix , where governs how an event of type influences the intensity of type . Empirically, incoming buy market orders excite further buy market orders on a sub-second timescale (momentum), while a large market sell tends to stimulate sell-side limit order cancellations (dealers pulling quotes in anticipation of further selling).
Simulation of a Hawkes process can be performed efficiently using the thinning algorithm (also called Lewis-Shedler rejection sampling): propose event times from a dominant Poisson process with rate , then accept each with probability . This avoids the need to evaluate the full history at each step.
Visible and hidden orders¶
Not all orders submitted to the exchange are fully visible in the public order book. Iceberg orders (also called reserve orders) display only a small portion of their true size, with the remainder hidden until the visible portion is consumed. Dark pool orders never appear in the public book at all, matching against contra-side flow in a separate venue. From the perspective of LOB modelling:
Visible orders affect the quoted depth and order imbalance features directly.
Hidden orders must be inferred from patterns in trade executions that exceed the displayed quote size. If a large market order consumes more volume than was visible, the excess reveals a hidden portion.
Detecting hidden liquidity is important for smart order routing: venues with high hidden volume offer better fill rates than their displayed book suggests. Ganchev et al. Ganchev et al., 2010 formulate dark pool routing as a censored exploration problem.
Order type, side, and size¶
Given that an event has occurred, we need models for its attributes:
Order type (limit, market, cancel): typically modelled as a categorical random variable with probabilities , or as separate intensity processes, one per order type.
Side (buy or sell): a Bernoulli random variable or separate processes for buy-side and sell-side activity. Short runs of same-side market orders — order-flow autocorrelation — are a well-documented empirical regularity.
Size: heavy-tailed. Log-normal distributions are tractable but underestimate large-order probability; empirically, order sizes often follow a power law Gabaix et al., 2003 with exponent close to .
Limit order price: placed relative to the best quote, with an approximately exponential distribution of depth (most limit orders cluster near the spread) and heavy tails further into the book Bouchaud et al., 2002. A common tractable choice is a geometric distribution with parameter : the probability of placement ticks from the best quote falls as .
Market impact models¶
When a trader executes an order of meaningful size, the act of trading moves prices against them. This market impact has two components. Temporary impact reflects the immediate price pressure: liquidity is consumed and prices move, but over a short horizon they partially recover as new orders replenish the book. Permanent impact reflects the long-run information content of the trade: if the execution reveals private information, prices adjust permanently to the new equilibrium. The decomposition is central to the Almgren–Chriss framework discussed in Chapter Optimal Execution Theory.
The square-root impact law¶
The most empirically robust model for the market impact of a meta-order (a large order executed incrementally over time) is the square-root law Tóth et al., 2011:
where is the total order size, is the average daily volume, is the daily price volatility, and –1.0 is an asset-class-dependent constant. The square-root form arises from the statistical mechanics of order book liquidity: if order sizes and available volume are power-law distributed, dimensional analysis forces impact to grow as .
The law holds remarkably consistently across asset classes, time horizons, and market conditions. Its main practical implication for execution algorithms is that market impact is a concave function of size: it is always preferable to split a large order into smaller pieces rather than executing it all at once. This is the rationale for VWAP, TWAP, and participation-rate schedules.
Kyle’s lambda¶
Kyle Kyle, 1985 developed the first formal microstructure model of market impact rooted in information asymmetry. In Kyle’s model, an informed trader with private information about a future value submits a market order ; noise traders submit aggregate flow ; and a competitive, risk-neutral market maker observes only total order flow and sets prices to break even. The linear equilibrium price impact is:
where is the standard deviation of the true asset value. The Kyle lambda is the permanent price impact per unit of order flow — higher when the information-to-noise ratio is large, i.e., when markets are dominated by informed trading. Empirically, is estimated from time-series regressions of price changes on signed order flow. It is wide during illiquid periods and tight in deep, competitive markets.
Temporary and permanent components¶
The Almgren–Chriss model (Chapter Optimal Execution Theory) decomposes total impact into a permanent component and a temporary component :
where is the effective execution price and is the volume traded at step . The permanent component corresponds to Kyle’s lambda — each unit of trading permanently shifts the equilibrium price by . The temporary component captures the within-slice resiliency cost: the bid-ask spread, queue displacement, and intraday price pressure from rapid execution.
The main limitation of the linear model is that it implies impact grows proportionally with , while empirically the square-root law applies. More refined models (see Cartea et al. (2015) for a review) replace the linear temporary impact with concave functions, at the cost of losing closed-form solutions to the execution optimization problem.
Volume prediction models¶
Volume prediction — forecasting how much of an asset will trade in a given time bucket, or over the rest of the trading day — is a critical input to VWAP and participation-rate execution algorithms (Chapter Optimal Execution Theory). Accurate volume forecasts allow the algorithm to construct a target schedule that matches the natural market flow, minimizing schedule slippage.
Static volume curve¶
The simplest model is a static intraday volume curve estimated from historical data. Let denote the fraction of total daily volume that trades in bucket on day . The static curve is:
typically computed separately for different day types (Monday vs Friday, option expiry days, Federal Reserve announcement days, etc.). The curve exhibits the well-known U-shape: volume is elevated at the open (overnight news digestion, limit order accumulation) and at the close (index rebalancing, end-of-day institutional flows), with a midday trough.
The static curve is robust and easy to implement but ignores all intraday information. It is appropriate when the forecast horizon covers most of the remaining trading day and no intraday context is available. For shorter horizons where intraday context has accumulated, dynamic models are preferable.
Dynamic prediction with KNN¶
-nearest-neighbour (KNN) regression uses the partial intraday volume history to find “similar” historical days and predict the remaining volume profile from their realized outcomes. Given a feature vector capturing the cumulative volume fraction up to time (and optionally other context variables such as day-of-week, realized volatility, or the volume of a leading correlated instrument), the KNN forecast is:
where is the set of historical days most similar to the current feature vector under some distance metric (typically Euclidean or cosine distance). KNN requires no parametric assumptions about the volume curve shape and automatically adapts to the intraday context. Busseti and Boyd Busseti & Boyd, 2015 discuss this class of volume-adaptive VWAP strategies.
For large historical datasets, exact KNN search scales as per query. Approximate nearest-neighbour (ANN) methods — ball-trees, locality-sensitive hashing, or FAISS — reduce this to , making real-time volume prediction tractable over multi-year historical databases. ANN methods are discussed further in Chapter Data-Driven Methods in the context of retrieval-augmented models.
Total daily volume¶
Predicting the total day volume at the start of trading is useful for pre-trade cost estimation and capacity analysis. Relevant features include:
Lagged volume: yesterday’s total volume, the 5-day and 20-day rolling mean (trend in participation).
Volatility: high-volatility days tend to have elevated volume (the volume-volatility correlation is well documented).
Economic calendar: FOMC announcements, non-farm payrolls, options expiry, and index rebalancing days produce systematic volume spikes.
Return on open: a large gap at the open predicts elevated intraday activity as participants adjust positions.
Simple exponential smoothing, linear regression, and gradient boosting all perform well in practice; the choice matters less than feature engineering.
LOB features¶
The raw limit order book — the full set of resting limit orders at every price level — is a high-dimensional object. For machine learning models (short-term prediction, execution tactic design, market making), it is standard to compute a smaller set of LOB features that capture the economically relevant information. We document the most commonly used features here, as they are referenced throughout the remainder of this chapter and in Chapters Execution Tactics and Optimal Market Making.
Spread and mid-price¶
The bid-ask spread is the most basic LOB feature:
It measures the cost of an immediate round-trip trade (buy at ask, sell at bid) and proxies for the market maker’s compensation for adverse selection and inventory risk. Wide spreads indicate low liquidity; tight spreads indicate competition among liquidity providers.
The mid-price serves as the reference for fair value in microstructure models. Most LOB features are computed relative to .
Order imbalance¶
Order imbalance (OI) at the best quote captures the relative pressure of buy versus sell liquidity:
where and are the volumes resting at the best bid and ask prices respectively. ; a positive value means more buy-side liquidity is offered at the best quote, while negative indicates more sell-side supply.
Order imbalance is one of the strongest short-term predictors of mid-price movements available from LOB data. Cont, Stoikov, and Talreja Cont et al., 2010 document that OI predicts the sign of the next mid-price move with accuracy above 55% across different instruments and time periods. The mechanism is simple: if there is more volume at the best bid than at the best ask, an incoming market sell order will clear the ask quickly, causing the mid-price to tick down.
Multi-level order imbalance extends this to the full visible book by summing over price levels on each side:
The multi-level version is more robust to transient quote spoofing at the best level and more predictive at longer (5–30 second) horizons.
Trade flow imbalance¶
Trade flow imbalance (TFI) over a rolling window captures the net signed order flow from recent executions:
where for buyer-initiated trades and for seller-initiated trades, and is the trade volume. A positive TFI indicates recent net buying pressure. TFI is related to the concept of order flow toxicity discussed in Section Information asymmetry.
Depth and volatility features¶
Additional features commonly used in execution and prediction models include:
Depth ratio: total resting volume on the bid side vs ask side within ticks of mid, measuring the depth-weighted book imbalance.
Price impact estimate: — the cost per unit of consuming the full best-quote volume.
Micro-volatility: — rolling realized volatility at tick frequency.
Tick direction: the sign of the most recent mid-price change.
Table 1:Standard LOB features used in execution and market-making models.
Feature | Definition | Primary use |
|---|---|---|
Spread | Market making, adverse selection | |
Mid-price | Universal reference price | |
Order imbalance | Short-term direction prediction | |
Trade flow imbalance | Net signed volume fraction over | VPIN, momentum signals |
Micro-volatility | Rolling squared mid-price changes at tick frequency | Spread setting, risk management |
Multi-level OI | Sum of bid/ask levels imbalance | Medium-horizon prediction |
Probability of filling a limit order¶
Limit orders as a Poisson process¶
The fundamental uncertainty in passive execution is whether a resting limit order will be hit before the execution window closes. To model this, consider a sell limit order placed ticks above the current mid-price . The order fills when either (i) the mid-price rises by at least ticks, or (ii) an incoming market buy order is large enough to consume liquidity up to and including that price level. From the order-placer’s perspective, both mechanisms produce the same observable outcome: the order fills at a random time.
Following Avellaneda and Stoikov Avellaneda & Stoikov, 2008 and the empirical analysis of Cont, Stoikov, and Talreja Cont et al., 2010, we model fill events as a Poisson process with depth-dependent intensity:
where is the base fill rate (fills per unit time at zero depth, i.e., posting at the current mid-price) and is the depth sensitivity — the rate at which fill probability decays with distance from the mid-price. The exponential form captures the empirical observation that the limit order book thins out approximately exponentially with depth: the probability of being filled within a given time window falls rapidly as the order is placed further from the market.
The probability of a fill occurring within a time window of length is:
This increases with (more time, more chance of being hit) and decreases with (deeper placement, lower fill probability). The expected time to fill is , which grows exponentially with depth.

Figure 1:Fill probability model. Left: fill rate as a function of placement depth (in ticks) for different values of the depth sensitivity (base rate fill per minute). Right: probability of filling within a time window as a function of for three placement depths ( ticks; , ). The exponential form captures the rapid decay of fill probability with depth observed empirically in limit order books.
Calibration¶
In practice, and are calibrated from historical LOB data by regressing observed fill rates against placement depth. The standard approach uses a log-linear regression:
where is estimated as the empirical fill rate for orders placed at depth , computed from a historical dataset of limit orders and their outcomes. A maximum-likelihood estimator for exponentially distributed fill times is:
where is the number of orders that filled, and the denominator sums the “risk time” for each order at its posted depth. This requires joint estimation of via numerical optimization (e.g., gradient descent on the negative log-likelihood).
The parameters vary systematically across market conditions:
Asset class: equity markets in continuous auction typically show –2.0 fills per minute at zero depth and –3 per tick. Fixed income and FX markets with wider spreads have smaller and smaller — fill rates fall off more slowly because even deep orders can fill within a longer horizon.
Intraday variation: is elevated at the open and close (high volume), lower at midday. Incorporating as a deterministic function of time of day significantly improves fill-probability forecasts.
Regime dependence: during periods of elevated volatility or wide spreads, tends to decrease (the LOB is thinner and depth matters less), while may increase as market orders arrive more frequently.
Extensions and richer models¶
The simple two-parameter model is a strong baseline, but richer models can improve calibration and fill-probability estimation:
Additional features. Including LOB features (Section LOB features) alongside depth in the fill-rate model substantially improves predictive accuracy. Key covariates include the current spread (a wide spread indicates lower fill probability at a given depth relative to mid), order imbalance (an imbalanced book toward the same side as the order reduces fill probability), and micro-volatility (higher volatility increases fill probability by raising the chance that the mid-price moves to the order). A generalized fill-rate model takes the form:
where and are functions of the current LOB features, estimated via logistic regression, gradient boosting, or neural networks.
Monotonicity constraints. For use in optimization problems (such as the HJB tactic design in Chapter Execution Tactics), the fill-rate model must be monotone decreasing in : posting deeper must never increase fill rate. The exponential family with is monotone by construction. For richer ML models, monotonicity must be enforced explicitly, for example using isotonic regression post-processing or input-convex neural networks Amos et al., 2017.
Survival analysis. Fill time can be modelled directly as a survival time with a hazard function for the Poisson case, or with a more general accelerated failure-time or Cox proportional-hazard specification. This framework naturally handles censored observations (orders that are cancelled before filling).
Short-term price prediction¶
Short-term price prediction models attempt to forecast the direction (or magnitude) of mid-price movements over horizons of a few seconds to minutes using signals derived from the current and recent LOB state. These models underpin alpha signals in high-frequency trading strategies and feed into execution tactics that time aggressive order submission.
Order imbalance as a predictor¶
The simplest and most robust short-term predictor is order imbalance , introduced in Section LOB features. The key empirical finding is:
for a constant and a short prediction horizon (typically 1–10 seconds). When the bid side is heavier than the ask side (), the next mid-price movement is on average positive — the model predicts upward pressure. A simple logistic regression on predicts next-tick direction with accuracy of 55–65% in most liquid markets, a modest but statistically significant and economically meaningful edge.
The predictability of OI is consistent with the microstructure mechanism: a heavy bid side means that market sell orders are unlikely to clear the queue before a limit-order buy is executed, so the next trade is likely buyer-initiated, pushing the price up.
Machine learning models¶
Richer feature sets substantially improve prediction accuracy. A standard pipeline combines:
Feature engineering: compute the LOB features from Table 1 — multi-level OI, trade flow imbalance, spread, and micro-volatility — at multiple lagged timestamps.
Model: logistic regression (baseline), gradient boosting machines Friedman, 2001, or a recurrent neural network (LSTM Hochreiter & Schmidhuber, 1997).
Label: next mid-price direction (+1, 0, −1) or the signed return over the next events.
Gradient boosting and LSTM models typically achieve prediction accuracy of 58–68% in liquid equity markets when trained on rich LOB feature vectors, with the exact figure depending on the asset and time horizon.
Deep learning approaches¶
DeepLOB Zhang et al., 2019 processes the raw LOB snapshot — all bid and ask prices and volumes at the top levels — as a two-dimensional image using convolutional layers followed by an Inception module and an LSTM. By operating directly on the raw book rather than hand-crafted features, DeepLOB captures complex nonlinear interactions between price levels that summary statistics miss. Zhang et al. report accuracy of 72–78% on mid-price direction prediction at horizons of 10–500 events on NASDAQ equity data.
More recent work applies Transformer architectures Vaswani et al., 2017 directly to LOB event sequences, using self-attention to model the dependencies between order arrivals at different price levels and times. These models require substantial compute for training but achieve state-of-the-art accuracy on public LOB benchmark datasets.
A recurring practical caveat: prediction accuracy computed on held-out historical data tends to overestimate live performance due to regime shifts, microstructure changes, and adverse selection — sophisticated participants learn to avoid being on the wrong side of predictable order flow.
Information asymmetry¶
Information asymmetry in financial markets refers to the situation in which some market participants (informed traders) have access to private information about an asset’s future value, while others (noise traders, market makers) do not. The key consequence for LOBs is adverse selection: a market maker who passively quotes both sides of the book risks being consistently picked off by informed traders, losing on average on every trade with an informed counterparty.
The Glosten-Milgrom model¶
The Glosten-Milgrom model Glosten & Milgrom, 1985 provides the foundational account of how adverse selection determines the bid-ask spread. Chapter Market Making Fundamentals gives an economic overview and Chapter Optimal Market Making derives the equilibrium in full; here we recall the result and connect it to the LOB observables introduced above.
The model considers a market maker quoting bid and ask against two types of incoming order: a fraction from informed traders who know the true asset value — either with prior probability or with probability — and a fraction from uninformed noise traders who buy or sell for liquidity reasons. Letting denote the prior expected value, the zero-profit equilibrium yields:
and therefore:
The spread is proportional to the fraction of informed flow and the magnitude of the information event . When the competitive spread is zero; as informed flow increases, the spread widens so that losses on informed trades are subsidised by gains on uninformed ones.
From a LOB perspective, is not directly observable, but its short-run fluctuations leave a signature in order flow. When informed traders dominate one side of the book — buying because they expect — order flow becomes one-sided: trade flow imbalance rises and order imbalance shifts in the direction of the information. This is the microstructural link between adverse selection and the features of Section LOB features. The PIN and VPIN measures below operationalise this connection by estimating from observed order flow statistics.
PIN: Probability of Informed Trading¶
The PIN model Easley et al., 1996 provides an empirical measure of the fraction of order flow that is information-motivated. The model assumes:
With probability , a private-information event occurs each day (good news with probability , bad news with probability ).
On information days, informed traders arrive at Poisson rate on the same side as the news.
On all days, noise traders arrive at rate on each side.
The probability of an informed trade in a given transaction is:
The parameters are estimated by maximum likelihood from the daily counts of buys and sells . High PIN stocks experience wider spreads, higher price impact, and more adverse selection for market makers — consistent with the Glosten-Milgrom mechanism.
VPIN: Volume-synchronized PIN¶
The standard PIN model is estimated at daily frequency and requires structural assumptions about the information arrival process. Easley, López de Prado, and O’Hara Easley et al., 2012 proposed VPIN (Volume-synchronized Probability of Informed Trading) as a high-frequency, real-time measure of order flow toxicity.
VPIN replaces calendar time with a volume clock: trading activity is divided into equal-volume buckets of size . Within each bucket, buy volume and sell volume are estimated (e.g., using the Lee-Ready tick-sign algorithm or the bulk volume classification of Easley et al. (2012)). VPIN is the moving average of the normalized order flow imbalance over the last buckets:
High VPIN indicates that recent order flow is highly one-sided — a signature of informed trading. Easley et al. showed that VPIN was elevated in the minutes before the May 2010 Flash Crash, suggesting that high order-flow toxicity may be a leading indicator of liquidity stress. VPIN is closely related to the trade flow imbalance feature from Section LOB features.
Amihud illiquidity¶
The Amihud illiquidity ratio Amihud, 2002 measures price impact from daily data, without requiring high-frequency order-level information:
where is the absolute daily return and is the daily dollar trading volume on day , averaged over a -day window (typically trading days). The ratio measures how much price moves per dollar of volume: a high value indicates that the asset is illiquid and susceptible to large price impact. ILLIQ is widely used in cross-sectional studies of equity returns, where assets with higher illiquidity command a risk premium, and in bond market research where LOB data is often unavailable.
Simulation of LOBs¶
Probabilistic generative models¶
As discussed in Chapter Bayesian Modelling, a probabilistic generative model describes the joint probability distribution of the relevant variables of the problem. For a simulated limit order book, this means modelling the probability distribution of the orders, e.g. limit or market orders in a limit order book. A typical way to construct these generative models is to proceed hierarchically:
First, we model the distribution of the arrival of orders to the market. These are point processes in continuous time, and a natural choice of models are the jump processes introduced in Chapter Stochastic Calculus. The most simple process is the Poisson process, in which orders arrive independently. More realistic choices are for instance Hawkes processes (Section Models for order arrival), that incorporate the empirical observation that orders tend to cluster in time, something that can be explained if they are self-exciting.
Since a market has at least limit and market orders available, and possibly more, a second model can be used to choose the type of order conditional on the arrival of one order. This can be simply modelled with a categorical distribution (a generalization of a Bernoulli distribution for more than two discrete categories). Alternatively, a separate jump process can be modelled for each different order type.
Depending on the type of order, we have to model their parameters. The two simplest orders available in LOBs are limit and market orders. Limit orders have a side (buy or sell), a size and a price. Market orders only have side and size.
The side can be modelled in the same lines as the type of order: as a Bernoulli random variable or by modelling separate point processes for buy and sell.
The size is a continuous positive variable. A log-normal distribution can be used to model sizes, although empirical distributions typically show heavy tails, making power-law distributions more appropriate in some settings Gabaix et al., 2003. Notice that depending on the exponent, power-laws may not be well-defined probability distributions; in those cases, maximum order sizes can be included to truncate them.
Finally, the distributions of limit order prices are typically constructed relative to the mid-price, and sign-adjusted to make buy and sell distributions mostly positive. As discussed in Bouchaud et al., 2002, they are right-skewed and heavy-tailed, peaking near the best bid and ask. A simple tractable choice is a log-normal distribution, potentially shifted to place some mass at least up to the opposite best. Log-normal distributions do not have heavy tails, so power-laws are also commonly used.
Once we have a model for the generation of orders, we need to couple it with a matching engine as the one described in Chapter Market microstructure.
Agent-based models¶
Agent-based models take a different path for simulation of the order book. In this case, we define a set of agents that seek to capture the stylized behaviour of real market players. These agents are algorithms that given market information make decisions about placing orders in the limit order book. Their internal logic is parametrized so their behaviour can be calibrated externally to generate dynamics that are representative of real markets. As with probabilistic generative models, they need to be coupled with a matching engine in order to execute a real simulation.
To illustrate this paradigm, let us discuss the agent-based model from McGroarty et al. McGroarty et al., 2019. This model implements a fully functioning LOB populated by five agent types — market makers, liquidity consumers, momentum traders, mean reversion traders and noise traders — each designed to capture a distinct class of real-world market behaviour.
Time is pseudo-continuous: a simulated trading day is divided into a number of periods. At every period each agent is selected to act with a type-specific probability , where indexes the type of agent. When selected, an agent may submit, modify or cancel an order, or do nothing — mirroring the discretion of real participants. For instance, in the original article, the calibrated action probabilities are
Notice that higher corresponds to faster trading: noise traders are effectively ultra-high-frequency, while market makers and liquidity consumers act on a much slower timescale.
Market makers¶
Market makers aim to earn the bid–ask spread by posting limit orders simultaneously on both sides of the LOB while keeping an approximately flat inventory. Their order placement is informed by a short-term directional signal: at each step they compute a -period rolling mean of the order-sign time series to predict whether the next arriving order will be a buy or a sell. If they predict a buy, they size up their sell-side limit order, with a volume drawn from a uniform distribution . At the same time, they reduce their buy-side quote to a small residual volume ; the opposite applies when a sell is predicted. This asymmetric quoting allows market makers to lean against anticipated flow and reduces adverse selection.
Liquidity consumers¶
Liquidity consumers model large institutional investors — pension funds, asset managers — who must buy or sell a substantial block of shares over the course of a day while minimising market impact and transaction costs. At the start of each day the agent is randomly assigned a direction (buy or sell with equal probability) and an initial order size drawn from a uniform distribution . Execution is purely passive and incremental: each time the agent is selected it checks the volume available at the opposing best quote . If the remaining order it consumes exactly ; otherwise it takes all available . Only market orders are used, so every fill reduces the remaining balance until the block is fully executed.
Momentum traders¶
Momentum traders represent the widespread belief that recent price trends persist. Their signal is the rate of change (ROC) over a look-back window of periods:
When the agent submits a buy market order; when a sell market order. In both cases the order volume is proportional to the signal strength and the agent’s current wealth :
This wealth-scaling makes the agent’s footprint grow with realised profits, amplifying trending dynamics.
Mean reversion traders¶
Mean reversion traders operate on the opposite belief: that prices tend to revert to a short-term historical average. Their anchor is an exponential moving average (EMA) updated at each tick:
where is a recency discount factor. If the current price is standard deviations above the agent places a sell limit order one tick inside the best ask; if it is standard deviations below, a buy limit order one tick inside the best bid. By posting limit orders rather than market orders these agents add liquidity when prices overshoot, creating a restoring force.
Noise traders¶
Noise traders are typically the most active participants (as reflected in the calibrated probabilities, ) and capture the residual, non-strategic order flow always present in real markets. Each time a noise trader is selected it first chooses a side and then randomly selects an action type: submit a market order (probability ), submit a limit order (), or cancel the oldest outstanding order (). Order sizes are drawn from a log-normal distribution:
If a limit order is chosen, the price is determined by one of four sub-cases:
Crossing (probability ): the order is placed at the opposing best price, guaranteeing immediate (possibly partial) fill.
Inside spread (): the price is drawn uniformly between the current best bid and ask.
At the spread (): the order is placed at the best price on the agent’s side.
Off-spread (): the order is placed deeper in the book at a price drawn from a power-law distribution.
Calibration¶
The model has twenty-three input parameters in total. Calibration proceeds by computing statistical properties of the synthetic market data generated by the simulator — the Hurst exponent of volatility, autocorrelation of mid-price returns, autocorrelation of the order-sign series, and the exponent of a power-law price impact function — and minimising the distance to their empirical counterparts over a grid of parameters.
Exercises¶
Exercise 1 (Hawkes process stationarity): Show that the stationary mean intensity of a univariate Hawkes process is , and derive the condition for stationarity. Simulate the process using the thinning algorithm for and verify empirically that the sample mean intensity approaches .
Exercise 2 (Square-root impact): An asset has daily volatility and average daily volume shares. Using , estimate the market impact of orders of sizes shares. How does doubling the order size compare to trading twice as fast?
Exercise 3 (Fill probability MLE): Generate a synthetic dataset of limit orders placed at depths ticks, with fill times drawn from for . Cap each observation at a maximum window min (censored). Estimate by maximising the likelihood of the censored exponential model and compare to the true values.
Exercise 4 (Order imbalance predictor): Using the probabilistic generative model simulation from the notebook, compute and the subsequent mid-price change for each snapshot. Fit a logistic regression of on and report the in-sample accuracy. Why might accuracy fall in live trading?
Exercise 5 (PIN estimation): Simulate 50 trading days with , , , (buy and sell arrival rates per day). Compute the daily buy/sell counts and estimate the PIN by maximum likelihood. Compare the estimated PIN to the true value .
Exercise 6 (Agent-based model calibration): Using the McGroarty model notebook, vary the noise-trader action probability from 0.5 to 0.9. For each value, compute the Hurst exponent of realized volatility and the first-lag autocorrelation of the order-sign series. Identify the parameter value that best matches stylized facts from a liquid equity market.
- McGroarty, F., Booth, A., Gerding, E., & others. (2019). High frequency trading strategies, market fragility and price spikes: an agent based model perspective. Annals of Operations Research, 282, 217–244. 10.1007/s10479-018-3019-4
- Hawkes, A. G. (1971). Spectra of Some Self-Exciting and Mutually Exciting Point Processes. Biometrika, 58(1), 83–90. 10.1093/biomet/58.1.83
- Bacry, E., Mastromatteo, I., & Muzy, J.-F. (2015). Hawkes Processes in Finance. Market Microstructure and Liquidity, 1(1), 1550005. 10.1142/S2382626615500057
- Ganchev, K., Nevmyvaka, Y., Kearns, M., & Wortman Vaughan, J. (2010). Censored Exploration and the Dark Pool Problem. Communications of the ACM, 53(5), 99–107. 10.1145/1735223.1735248
- Gabaix, X., Gopikrishnan, P., Plerou, V., & Stanley, H. E. (2003). A theory of power-law distributions in financial market fluctuations. Nature, 423(6937), 267–270. 10.1038/nature01624
- Bouchaud, J.-P., Mézard, M., & Potters, M. (2002). Statistical properties of stock order books: empirical results and models. Quantitative Finance, 2(4), 251–256. 10.1088/1469-7688/2/4/301
- Tóth, B., Lempérière, Y., Deremble, C., de Lataillade, J., Kockelkoren, J., & Bouchaud, J.-P. (2011). Anomalous Price Impact and the Critical Nature of Liquidity in Financial Markets. Physical Review X, 1(2), 021006. 10.1103/PhysRevX.1.021006
- Kyle, A. S. (1985). Continuous Auctions and Insider Trading. Econometrica, 53(6), 1315–1335. 10.2307/1913210
- Cartea, Á., Jaimungal, S., & Penalva, J. (2015). Algorithmic and High-Frequency Trading. Cambridge University Press.
- Busseti, E., & Boyd, S. (2015). Volume Weighted Average Price Optimal Execution. arXiv Preprint arXiv:1509.08503. https://arxiv.org/abs/1509.08503
- Cont, R., Stoikov, S., & Talreja, R. (2010). A Stochastic Model for Order Book Dynamics. Operations Research, 58(3), 549–563. 10.1287/opre.1090.0780
- Avellaneda, M., & Stoikov, S. (2008). High-frequency trading in a limit order book. Quantitative Finance, 8(3), 217–224. 10.1080/14697680701381228
- Amos, B., Xu, L., & Kolter, J. Z. (2017). Input Convex Neural Networks. Proceedings of the 34th International Conference on Machine Learning, 146–155.
- Friedman, J. H. (2001). Greedy Function Approximation: A Gradient Boosting Machine. Annals of Statistics, 29(5), 1189–1232.
- Hochreiter, S., & Schmidhuber, J. (1997). Long Short-Term Memory. Neural Computation, 9(8), 1735–1780.