Quant techniques · market making

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.

1λ(δ)=A e−kδ\lambda(\delta) = A\,e^{-k\delta} Orders arrive at your quote at a rate that falls exponentially with its distance δ from the mid price.
2r=s−q γ σ2(T−t)r = s - q\,\gamma\,\sigma^2 (T - t) Reservation price: the mid s, shifted against your inventory q. γ is risk aversion, σ the price vol, T − t the time left.
3δa+δb=γσ2(T−t)+2γln⁡ ⁣(1+γk)\delta^a + \delta^b = \gamma\sigma^2(T - t) + \tfrac{2}{\gamma}\ln\!\left(1 + \tfrac{\gamma}{k}\right) Total spread: an inventory-risk term that shrinks towards the close, plus a term set by how fast fills drop off.
4bid=r−12(δa+δb),ask=r+12(δa+δb)\text{bid} = r - \tfrac12(\delta^a + \delta^b),\qquad \text{ask} = r + \tfrac12(\delta^a + \delta^b) Quote symmetrically around r, not around s.
The setup

Earning the spread, carrying the risk

The mid price moves as Brownian motion with volatility σ. You post an ask at distance δa\delta^a above the mid and a bid at δb\delta^b below. Market orders hit your ask at rate Ae−kδaA e^{-k\delta^a} and your bid at rate Ae−kδbA e^{-k\delta^b}. 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, E[−e−γWT]E[-e^{-\gamma W_T}], 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.

Step 2

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:

v(q)=q s−12 γ q2σ2(T−t)v(q) = q\,s - \tfrac12\,\gamma\,q^2\sigma^2 (T - t)

The price at which you’d be indifferent about buying one more share is v(q+1)−v(q)=s−12γσ2(T−t)(2q+1)v(q+1) - v(q) = s - \tfrac12\gamma\sigma^2(T-t)(2q + 1), and about selling one is v(q)−v(q−1)=s−12γσ2(T−t)(2q−1)v(q) - v(q-1) = s - \tfrac12\gamma\sigma^2(T-t)(2q - 1). Their average is the reservation price r=s−qγσ2(T−t)r = s - q\gamma\sigma^2(T - t).

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.

Step 3

The width: risk plus order-flow sensitivity

The spread has two parts.

  • γσ2(T−t)\gamma\sigma^2(T-t): compensation for inventory risk. It shrinks to zero at the close, when an extra share can’t lose much more.
  • 2γln⁡(1+γ/k)\tfrac{2}{\gamma}\ln(1 + \gamma/k): 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 2/k2/k, 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 0.4+20ln⁡(1.0667)≈1.690.4 + 20\ln(1.0667) \approx 1.69, and at the close it is about 1.29.

risk aversion γ

Inventory through one day (same prices and order flow)

End-of-day P&L over 500 days

inventory-aware (Avellaneda–Stoikov)symmetric: same spread, centred on mid
Strategymean P&Ls.d. P&Ls.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 lower

What 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 λ(δ)\lambda(\delta) falling with δ: wider quotes earn more per fill and get fewer fills.
Practice

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
r=100−5×0.1×4×1=98r = 100 - 5 \times 0.1 \times 4 \times 1 = 98
SpreadWith the same parameters and k = 1.5, what is the total spread, and where are your bid and ask?
Show answer
0.4+20.1ln⁡(1+0.11.5)=0.4+1.291=1.6910.4 + \frac{2}{0.1}\ln\left(1 + \frac{0.1}{1.5}\right) = 0.4 + 1.291 = 1.691

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 2/k2/k, since 2γln⁡(1+γ/k)→2/k\tfrac{2}{\gamma}\ln(1 + \gamma/k) \to 2/k. 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
140 e−1.5×0.845=140×0.282≈39140\,e^{-1.5 \times 0.845} = 140 \times 0.282 \approx 39
Risk-neutralA risk-neutral market maker chooses δ to maximise δ·A·e^{−kδ}. Find δ.
Show answer

The derivative is Ae−kδ(1−kδ)=0Ae^{-k\delta}(1 - k\delta) = 0, 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 q2σ2τq^2\sigma^2\tau, so the risk penalty is 12γq2σ2τ\tfrac12\gamma q^2\sigma^2\tau. The reservation price is the marginal value of one share, the derivative of that penalty with respect to q, which is linear: qγσ2τq\gamma\sigma^2\tau.

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.