Market making with inventory: the Avellaneda–Stoikov quotes
A market maker posts a bid and an ask and earns the gap when both sides trade. The risk is that they don’t trade evenly. Sell to five buyers in a row and you’re short five shares in a market that may be going up. The Avellaneda–Stoikov model (2008) gives a clean answer to “where should I quote?”: centre your quotes on a price that leans against your inventory, and set the width by how sensitive order flow is to your prices.
Earning the spread, carrying the risk
The mid price moves as Brownian motion with volatility σ. You post an ask at distance above the mid and a bid at below. Market orders hit your ask at rate and your bid at rate . Quote further away and you earn more per fill but fill less often. At the end of the day, T, you mark your inventory at the mid.
You want to maximise expected exponential utility, , of final wealth. That’s a stochastic control problem with a Hamilton–Jacobi–Bellman equation, and Avellaneda and Stoikov solved it approximately, giving steps 2 and 3. Both have clear intuition.
The reservation price leans against your position
Suppose you hold q shares and will mark them at the close, T − t from now. With CARA utility, the certainty-equivalent value of that position is its expected value minus a risk penalty:
The price at which you’d be indifferent about buying one more share is , and about selling one is . Their average is the reservation price .
So if you’re long, your reservation price is below the mid. Quoting around it moves your ask down (more likely to sell) and your bid down (less likely to buy), which pushes inventory back towards zero. The lean is stronger when you’re more risk-averse, when the price is more volatile, when you hold more, and when there’s more time left for the price to move against you.
The width: risk plus order-flow sensitivity
The spread has two parts.
- : compensation for inventory risk. It shrinks to zero at the close, when an extra share can’t lose much more.
- : the order-flow term. It is set by k, how fast the fill rate falls as you quote wider. If k is small (fill rate barely depends on price), quote wide. As γ → 0 it tends to , the spread a risk-neutral monopolist would charge.
With the paper’s parameters (σ = 2, γ = 0.1, k = 1.5, T = 1), the spread at the open is , and at the close it is about 1.29.
Inventory through one day (same prices and order flow)
End-of-day P&L over 500 days
| Strategy | mean P&L | s.d. P&L | s.d. of final inventory |
|---|
The figure reproduces the paper’s simulation: a $100 stock, 200 time steps, A = 140, k = 1.5. The symmetric strategy quotes the same spread but centred on the mid, ignoring inventory. On a typical run the inventory-aware strategy makes a few percent less (about 65 against 68), but its daily P&L has roughly half the standard deviation (about 6.7 against 13) and its end-of-day inventory is much smaller. With γ = 0.01 the two strategies become almost the same; with γ = 0.5 the skew is aggressive and the spread is wide.
import numpy as np
def as_quotes(s, q, t, T=1.0, sigma=2.0, gamma=0.1, k=1.5):
"""Avellaneda–Stoikov bid and ask for mid s, inventory q, time t."""
tau = T - t
r = s - q * gamma * sigma**2 * tau
spread = gamma * sigma**2 * tau + (2 / gamma) * np.log(1 + gamma / k)
return r - spread / 2, r + spread / 2
print(as_quotes(100, 0, 0)) # (99.155, 100.845)
print(as_quotes(100, 5, 0)) # (97.155, 98.845): long 5, so lean lowerWhat the model leaves out
- Adverse selection. Real fills are not random: you tend to get filled just before the price moves against you. Practical market makers widen quotes or skew them using short-term price signals.
- Ticks and queues. Prices are discrete, and where you sit in the queue matters as much as your price.
- No fixed end time. Many desks run continuously. Guéant, Lehalle and Fernandez-Tapia (2013) solved the version with an inventory limit and showed that, far from the horizon, the quotes settle to time-independent values.
- The approximation. Steps 2 and 3 come from expanding the HJB solution for small inventory. They are a very good guide, not the exact optimum.
Where people slip in interviews
- Skewing the wrong way. Long inventory means you want to sell: lower both quotes, so the ask is more attractive and the bid less.
- Thinking the spread is centred on the mid. It’s centred on the reservation price.
- Ignoring the time term. The inventory penalty scales with T − t. Near the close, an extra share costs little risk, and quotes tighten.
- Treating the fill rate as fixed. The whole trade-off comes from falling with δ: wider quotes earn more per fill and get fewer fills.
Try these before you open the answer
Warm-upMid 100, σ = 2, γ = 0.1, T − t = 1, and you are long 5. What's your reservation price?Show answer
SpreadWith the same parameters and k = 1.5, what is the total spread, and where are your bid and ask?Show answer
Bid ≈ 98 − 0.845 = 97.155, ask ≈ 98.845. Your ask is now below the mid, so you’re likely to sell soon.
LimitWhat do the quotes become as γ → 0?Show answer
The reservation price tends to s (no inventory penalty) and the spread tends to , since . A risk-neutral market maker quotes symmetrically, at distance 1/k on each side.
Fill rateA = 140 per day, k = 1.5, and your ask is 0.845 above the mid. How many buy orders do you expect per day at that quote?Show answer
Risk-neutralA risk-neutral market maker chooses δ to maximise δ·A·e^{−kδ}. Find δ.Show answer
The derivative is , so δ = 1/k. Each side sits 1/k from the mid, matching the γ → 0 limit.
StretchWhy does the inventory penalty grow linearly in q, but the risk of the position grows like q²?Show answer
The variance of the position’s value is , so the risk penalty is . The reservation price is the marginal value of one share, the derivative of that penalty with respect to q, which is linear: .
The P&L and inventory numbers match a 1,000-day simulation with the paper’s parameters. The figure simulates 500 days in your browser for each setting.