What does Order Books, Hawkes Processes and Toxic Flow conclude, in numbers, about “Inventory Risk and Optimal Market Making: the Avellaneda–Stoikov Equations”?

Answer: The Avellaneda–Stoikov reservation price \(s - q\gamma\sigma^2(T-t)\) and total-spread formula check out, but the spread formula depends on exponential arrival intensities, an expansion in inventory and a first-order approximation of the order-arrival term. The exact solution of Guéant and co-authors shows that optimal quotes hardly depend on time away from the horizon; with the paper's parameters and one unit of time remaining, the approximation already overstates the reservation-price shift at inventory 1 about eightfold (−0.400 against −0.052). Re-running the paper's simulation gives results close to the paper's; quoting by the exact solution raises mean profit at \(\gamma = 1\) from 31.2 to 63.9. There is no adverse selection in the model, which is the starting point of the experiment designed in Chapter 8.

Scope of the numbers: Why does a market maker quote a spread? Why do orders arrive in clusters? Can "toxic" order flow be measured from trade data? This book presents mathematical models for teaching and research and is not investment or trading advice. Marked boxes separate published evidence, runnable Python calculations (16 programs), classical sources and the author's models and hypotheses; all data in the book are fictional or simulated.

中文版

Data table

The numbers below are printed verbatim by the chapter's Python program and can be reproduced by running it. standard-library Python onlyprinted values that match the answer: 31.2, 63.9

gammastrategymean spreadprofitsd(profit)final qsd(q)profit/sd
0.01inventory1.3568.69.3-0.035.37.4
0.01symmetric1.3569.214.5+0.079.04.8
0.01exact ODE1.3468.810.2+0.015.66.8
0.1inventory1.4964.86.5+0.072.99.9
0.1symmetric1.4968.614.3+0.018.84.8
0.1exact ODE1.3467.97.3+0.043.09.2
1.0inventory3.0331.24.8-0.031.66.5
1.0symmetric3.0344.010.8-0.075.24.1
1.0exact ODE1.2163.95.6-0.021.611.4

Key formula

\[\lambda(\delta) = A\,e^{-k\delta},\]
Show the full program
# Re-running the simulation design of Avellaneda & Stoikov (2008): s0 = 100, T = 1,
# sigma = 2, dt = 0.005, A = 140, k = 1.5; the mid moves +-sigma sqrt(dt) each step, a
# quote at distance delta is filled with probability A exp(-k delta) dt. Strategies:
#  inventory - AS quotes around the reservation price s - q g sig^2 (T - t)
#  symmetric - quotes symmetric about the mid; spread = inventory strategy's mean spread
#  exact     - quotes from the exact ODE solution (Gueant et al. 2013, |q| <= 30)
# 1,000 sessions per row, common random numbers across strategies within a session.
import math, random, statistics

S0, T, SIG, DT, A, K = 100.0, 1.0, 2.0, 0.005, 140.0, 1.5
NSTEP = round(T / DT)

def exact_table(g, Q=30, sub=25):
    a = K * g * SIG ** 2 / 2; eta = A * (1 + g / K) ** -(1 + K / g)
    c = math.log(1 + g / K) / g; h = DT / sub; v = [1.0] * (2 * Q + 1); tab = [None]
    def f(w):
        return [-a * (i - Q) ** 2 * w[i] + eta * ((w[i - 1] if i else 0.0)
                + (w[i + 1] if i < 2 * Q else 0.0)) for i in range(2 * Q + 1)]
    for _ in range(NSTEP):                                    # tab[j]: tau = j * DT
        for _ in range(sub):
            k1 = f(v); k2 = f([x + h / 2 * y for x, y in zip(v, k1)])
            k3 = f([x + h / 2 * y for x, y in zip(v, k2)])
            k4 = f([x + h * y for x, y in zip(v, k3)])
            v = [x + h / 6 * (p + 2 * q + 2 * r + s)
                 for x, p, q, r, s in zip(v, k1, k2, k3, k4)]
            m = max(v); v = [x / m for x in v]
        tab.append({q: (math.log(v[q + Q] / v[q + Q + 1]) / K + c if q < Q else 99.0,
                        math.log(v[q + Q] / v[q + Q - 1]) / K + c if q > -Q else 99.0)
                    for q in range(-Q, Q + 1)})
    return tab

def run(g, kind, seed, half=None, tab=None):
    rng = random.Random(seed); s, x, q, spreads = S0, 0.0, 0, []
    for j in range(NSTEP):
        tau = T - j * DT
        if kind == "inventory":
            r = s - q * g * SIG ** 2 * tau
            sp = g * SIG ** 2 * tau + 2 / g * math.log(1 + g / K)
            bid, ask = r - sp / 2, r + sp / 2
        elif kind == "symmetric":
            bid, ask = s - half, s + half
        else:
            db, da = tab[NSTEP - j][max(-30, min(30, q))]
            bid, ask = s - db, s + da
        spreads.append(ask - bid)
        u1, u2, u3 = rng.random(), rng.random(), rng.random()
        if u1 < A * math.exp(-K * (ask - s)) * DT:
            q -= 1; x += ask
        if u2 < A * math.exp(-K * (s - bid)) * DT:
            q += 1; x -= bid
        s += SIG * math.sqrt(DT) * (1 if u3 < 0.5 else -1)
    return x + q * s, q, statistics.fmean(spreads)

if __name__ == "__main__":
    print("gamma  strategy   mean spread  profit  sd(profit)  final q  sd(q)  profit/sd")
    for g in (0.01, 0.1, 1.0):
        inv = [run(g, "inventory", sd) for sd in range(1000)]
        half = statistics.fmean(r[2] for r in inv) / 2; tab = exact_table(g)
        rows = {"inventory": inv,
                "symmetric": [run(g, "symmetric", sd, half=half) for sd in range(1000)],
                "exact ODE": [run(g, "exact", sd, tab=tab) for sd in range(1000)]}
        for name, rs in rows.items():
            p = [r[0] for r in rs]; qq = [r[1] for r in rs]
            m, sd = statistics.fmean(p), statistics.stdev(p)
            print(f" {g:<5} {name:10s}  {statistics.fmean(r[2] for r in rs):6.2f}  "
                  f"  {m:6.1f}   {sd:6.1f}    {statistics.fmean(qq):+6.2f}"
                  f"  {statistics.stdev(qq):5.1f}   {m / sd:6.1f}")

Single source and citation

Fan, Y. (2026). High-Frequency Limit Order Book Microstructure, Hawkes Self-Exciting Point Processes and Adverse-Selection Flow Toxicity (Version 1.0.0), Chapter 2: Inventory Risk and Optimal Market Making: the Avellaneda–Stoikov Equations. 5D Library. https://doi.org/10.5281/zenodo.23828065

DOI: 10.5281/zenodo.23828065 · Read the monograph · 5DL-B-045 · v1.0.0 · CC-BY-NC-ND-4.0

BibTeX
@book{fan2026045,
  author    = {Fan, Yafu},
  title     = {High-Frequency Limit Order Book Microstructure, Hawkes Self-Exciting Point Processes and Adverse-Selection Flow Toxicity},
  year      = {2026},
  publisher = {5D Library},
  edition   = {1.0.0},
  doi       = {10.5281/zenodo.23828065},
  url       = {https://doi.org/10.5281/zenodo.23828065}
}

Other chapter answers in this book