The Market Making Book

6. The Mathematics of Optimal Quoting

Avellaneda–Stoikov (2008): the two formulas that run half the market making bots on Earth — derived gently, then driven with sliders.

Part II · Chapter 6

The setup

Avellaneda and Stoikov model a market maker over a horizon ending at time T (end of day, or market resolution). Three ingredients:

  • The mid-price follows a Brownian motion with volatility σ: it diffuses randomly, no drift.
  • If you quote at distance δ from the mid, fills arrive as a Poisson process with intensity λ(δ) = A·e−kδ — quote further away, get filled exponentially less often. The constant k measures how price-sensitive the flow is (a dense, competitive book has high k).
  • You maximize expected exponential utility of final wealth with risk aversion γ — meaning variance of your inventory genuinely hurts you, not just losses.

Solving the resulting Hamilton–Jacobi–Bellman equation (a dynamic-programming equation: "act optimally now, assuming you'll act optimally forever after") yields two famous results.

Parable · The chess endgame How do engines play chess? Not forward but backward: they know the value of final positions (win/lose/draw), so they can value the positions one move earlier, and one move before that, all the way back to the present. The HJB equation is exactly this trick in continuous time. At t = T the market maker's "game" ends and the value of every inventory level is known (you mark to market, or the contract settles). Stepping backward from that certainty, the equation asks at every instant: given that future-me will quote optimally, what quotes maximize my utility right now? The two formulas below are the closed-form answer — the entire endgame compressed into algebra.

Result 1 — The reservation price

Reservation (indifference) price r = sq · γ · σ² · (Tt) What the symbols mean r — your reservation price: the fair value to you, given what you're holding  ·  s — the market mid-price  ·  q — your inventory: positive if you're long, negative if short, 0 if flat  ·  γ (gamma) — your risk aversion: how much you dislike holding risk (bigger γ = more cautious)  ·  σ² (sigma squared) — the variance of the price: volatility σ, squared  ·  Tt — time remaining: T is when the game ends (close or settlement), t is now.

Your personal fair value r is the market mid s, shifted against your inventory q. Long 10 contracts? Your private value sits below the mid — you'd rather sell. The shift grows with:

  • γ — how much you hate risk;
  • σ² — variance, not volatility: doubling σ quadruples the skew;
  • (T−t) — how long you'll have to live with the position. Near the close (or a contract's resolution), the skew vanishes: there's no time left for the position to hurt you.
Parable · The money changer at closing time At 9 a.m., a money changer who's accumulated too many euros quotes noticeably worse euro-buying prices — there's a whole risky day ahead of holding them. At 4:55 p.m., five minutes before settling up, the same pile barely moves his quotes: almost no time remains for the euro to move against him. That's the (T−t) term breathing.

Result 2 — The optimal spread

Optimal total spread (quotes are set at r ± δ/2) δtotal = γ · σ² · (Tt)  +  (2/γ) · ln(1 + γ/k) What the symbols mean δtotal (delta) — the full distance between your bid and your ask; you post half of it on each side of the reservation price r  ·  γ, σ², Tt — same as above: risk aversion, price variance, time remaining  ·  k — order-flow decay: how quickly your chance of getting filled dies as you quote further from the mid (big k = dense, competitive book)  ·  ln — the natural logarithm, a function on any calculator; here it just makes the competition term shrink gently as k grows.

Two terms, two jobs. The first is the risk premium — wider when volatile and when far from the horizon. The second is the competition term: when the book is dense and flow is price-sensitive (large k), the log shrinks and you must quote tighter to get filled at all. You then center this spread on the reservation price, not the mid — that asymmetry is what steers inventory home.

interactive — avellaneda–stoikov explorer
Reservation r
Bid
Ask
Spread
The white line is the mid s = 100; the amber line is your reservation price r. Go long (q > 0) and watch both quotes sink below the mid — you're discounting to sell. Now drag T−t toward 0 and watch the whole machine relax: skew and risk-spread melt as resolution approaches. This melting is exactly the "vol crush" you'll exploit in sports markets (Chapter 8).

Where the competition term comes from: the fill-rate trade-off

The second half of the spread formula deserves its own picture, because it encodes the most fundamental tension in market making. Quote far from the mid and each fill is lucrative but rare; quote close and fills pour in worth almost nothing. With fill intensity λ(δ) = A·e−kδ, the expected profit rate from one quote is the product:

Expected profit rate at distance δ (risk-neutral) π(δ) = δ · A · e−kδ   ⇒   π′(δ*) = 0  at  δ* = 1/k What the symbols mean δ (delta) — how far from the mid you place your quote  ·  π(δ) (pi) — your expected profit per unit of time at that distance: (profit per fill) × (fills per second)  ·  A — how often orders would hit a quote sitting right at the mid (the base fill rate)  ·  e−kδ — exponential decay: each extra tick of distance multiplies your fill rate by the same factor below 1; k sets how brutal that decay is  ·  π′(δ*) = 0 — calculus shorthand for "the peak of the hump": where the slope (π′, the derivative) is zero, profit is maximized, and that happens at δ* = 1/k.

A hump with a single peak at exactly δ* = 1/k: the denser and more price-sensitive the book (large k), the tighter the optimal quote. This is the risk-neutral skeleton of the AS competition term; risk aversion (γ) then nudges the quote off this peak, trading a little expected profit for a lot less inventory variance.

interactive — the fill-rate trade-off
Optimal δ* = 1/k
Your expected profit
% of the optimum
Green: how often you get filled, decaying exponentially with distance. Dim white: how much each fill earns, growing linearly. Amber: their product — the money. Drag your quote (the marker) and feel how forgiving the peak is near δ* and how brutally the hump collapses when k rises: in a dense book there is simply less room to be clever. Every quoting engine on Earth is climbing this hump in real time.

Guéant–Lehalle–Fernandez-Tapia: making it production-grade

Raw AS has two practical problems: inventory is unbounded, and the formulas are asymptotic approximations. Guéant, Lehalle and Fernandez-Tapia (2013) re-solved the problem with a hard inventory limit |q| ≤ Q and showed the HJB system collapses into linear ordinary differential equations with clean closed-form approximations. The behavioral upshot: when inventory hits the bound, you simply stop quoting that side. GLFT is what you should actually implement: same intuition, bounded risk, cheap to compute. (Guéant later extended it to multi-asset market making — useful when quoting correlated markets like several tennis matches at once.)

What the model leaves out

  • Prices aren't Brownian — they jump (Chapter 8 fixes this for event markets).
  • Adverse selection isn't modeled — fills are assumed information-free Poisson arrivals. In reality you must bolt on toxicity monitoring (Chapter 7).
  • Parameters aren't constants — σ, k, and even your effective γ shift by regime. The frontier (Chapter 15) is learning them online.
The 30-second takeawayQuote around a reservation price that leans against your inventory (q·γ·σ²·(T−t)), with a spread = risk premium + competition term. Everything else in algorithmic market making is decoration on these two formulas.

On this page

GitHubGitHub repository