What does Order Books, Hawkes Processes and Toxic Flow conclude, in numbers, about “Practice and a Pre-Registered Test”?

Answer: Chapter 8 gives a four-step checklist (adverse selection, order flow, inventory, execution) and a pre-registered simulated-matching experiment comparing the cross-session Sharpe ratios of inventory-skewed Avellaneda–Stoikov quotes and fixed symmetric quotes under toxic pulses on a simulator frozen by an independent third party (single primary outcome their difference, smallest effect of interest 0.31, 8,600 paired sessions, double-blind running, decision rule written as code). 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.

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: 0.31, 8600

pilot (4,000 paired sessions): SR_X 9.06 (mean 64.5, sd 7.1),
   SR_Y 3.09 (mean 63.6, sd 20.6)
   correlation of paired P&L 0.33; pilot difference +5.97; mean max|q|: X 4.4, Y 11.6
   with a pulse (2,041): SR_X 8.33, SR_Y 2.37, mean P&L X 64.1, Y 59.0
   without      (1,959): SR_X 10.09, SR_Y 5.21, mean P&L X 65.0, Y 68.4
SESOI = 10 % of SR_Y = 0.31; asymptotic variance 44.0 (normal theory)
   90 % power, two-sided alpha 0.05: 4,844 paired sessions
   s.e. of SR_X - SR_Y at n = 4,844: normal theory 0.095, bootstrap 0.121
   robust n 7,779; plus 10 % for failed runs, rounded up: plan 8,600
sensitivity, paired sessions (robust)       SESOI: 5 %     10 %     20 % of SR_Y
   bootstrap s.e. as estimated              31,114    7,779    1,945
   variance 50 % higher                     46,671   11,668    2,917
Show the full program
# Sample size for the Chapter 8 pre-registered simulation experiment. Arms, on the SAME
# simulated sessions (paired seeds): X = inventory-aware Avellaneda-Stoikov quotes
# (gamma 0.1), Y = fixed symmetric quotes whose spread equals X's mean spread.
# Primary outcome: Sharpe ratio of terminal session P&L across sessions, SR_X - SR_Y.
# PILOT ENVIRONMENT (a planning assumption, not the trial's simulator): the AS setting of
# p04 plus toxic pulses. With probability 1/2 a session contains one pulse of 20 steps at
# a random time; during it the mid drifts 0.15 per step in a random direction and, each
# step, an informed order hits the quote on the drift side with probability 0.5 whenever
# that quote is closer to the mid than the drift still to come.
import math, random, statistics

S0, T, SIG, DT, A, K, G = 100.0, 1.0, 2.0, 0.005, 140.0, 1.5, 0.1
NSTEP = round(T / DT); Z = statistics.NormalDist().inv_cdf

def session(seed, kind, half=None):
    rng = random.Random(seed); s, x, q, sp, qmax = S0, 0.0, 0, [], 0
    pulse = rng.random() < 0.5; start = rng.randrange(0, NSTEP - 20)
    sign = 1 if rng.random() < 0.5 else -1
    for j in range(NSTEP):
        tau = T - j * DT
        if kind == "X":
            r = s - q * G * SIG ** 2 * tau
            h = (G * SIG ** 2 * tau + 2 / G * math.log(1 + G / K)) / 2
            bid, ask = r - h, r + h
        else:
            bid, ask = s - half, s + half
        sp.append(ask - bid)
        u1, u2, u3, u4 = rng.random(), 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
        on = pulse and start <= j < start + 20
        gain = 0.15 * (start + 20 - j)                    # drift still to come
        if on and u4 < 0.5:                               # informed order
            if sign > 0 and ask - s < gain:
                q -= 1; x += ask
            elif sign < 0 and s - bid < gain:
                q += 1; x -= bid
        s += SIG * math.sqrt(DT) * (1 if u3 < 0.5 else -1) + (0.15 * sign if on else 0.0)
        qmax = max(qmax, abs(q))
    return x + q * s, qmax, statistics.fmean(sp)

def sr(v):
    return statistics.fmean(v) / statistics.stdev(v)

def avar(a, b, rho):                                      # Jobson-Korkie / Memmel
    return 2 * (1 - rho) + 0.5 * (a * a + b * b) - rho * rho * a * b

if __name__ == "__main__":
    n0 = 4000
    X = [session(i, "X") for i in range(n0)]
    half = statistics.fmean(r[2] for r in X) / 2
    Y = [session(i, "Y", half) for i in range(n0)]
    px, py = [r[0] for r in X], [r[0] for r in Y]
    a, b, rho = sr(px), sr(py), statistics.correlation(px, py)
    mx, sx, my, sy = (statistics.fmean(px), statistics.stdev(px), statistics.fmean(py),
                      statistics.stdev(py))
    print(f"pilot ({n0:,} paired sessions): SR_X {a:.2f} (mean {mx:.1f}, sd {sx:.1f}),"
          f"\n   SR_Y {b:.2f} (mean {my:.1f}, sd {sy:.1f})")
    print(f"   correlation of paired P&L {rho:.2f}; pilot difference {a - b:+.2f};"
          f" mean max|q|: X {statistics.fmean(r[1] for r in X):.1f},"
          f" Y {statistics.fmean(r[1] for r in Y):.1f}")
    pul = [i for i in range(n0) if random.Random(i).random() < 0.5]   # pulse sessions
    npl = [i for i in range(n0) if i not in set(pul)]
    for lab, ids in (("with a pulse", pul), ("without", npl)):
        print(f"   {lab:12s} ({len(ids):,}): SR_X {sr([px[i] for i in ids]):.2f},"
              f" SR_Y {sr([py[i] for i in ids]):.2f}, mean P&L X"
              f" {statistics.fmean(px[i] for i in ids):.1f}, Y"
              f" {statistics.fmean(py[i] for i in ids):.1f}")
    sesoi = 0.10 * b
    v = avar(a, b, rho); n = (Z(0.975) + Z(0.90)) ** 2 * v / sesoi ** 2
    print(f"SESOI = 10 % of SR_Y = {sesoi:.2f}; asymptotic variance {v:.1f}"
          f" (normal theory)")
    print(f"   90 % power, two-sided alpha 0.05: {math.ceil(n):,} paired sessions")
    rng = random.Random(8); m = math.ceil(n); diffs = []
    for _ in range(400):                                  # bootstrap check of the s.e.
        idx = [rng.randrange(n0) for _ in range(m)]
        diffs.append(sr([px[i] for i in idx]) - sr([py[i] for i in idx]))
    se_b = statistics.stdev(diffs); se_n = math.sqrt(v / m)
    print(f"   s.e. of SR_X - SR_Y at n = {m:,}: normal theory {se_n:.3f},"
          f" bootstrap {se_b:.3f}")
    n_rob = math.ceil(n * (se_b / se_n) ** 2)
    plan = math.ceil(n_rob * 1.1 / 100) * 100
    print(f"   robust n {n_rob:,}; plus 10 % for failed runs, rounded up: plan {plan:,}")
    print("sensitivity, paired sessions (robust)       SESOI: 5 %     10 %     20 %"
          " of SR_Y")
    for lab, f in (("bootstrap s.e. as estimated", 1.0), ("variance 50 % higher", 1.5)):
        row = [math.ceil((Z(0.975) + Z(0.90)) ** 2 * v * (se_b / se_n) ** 2 * f
                         / (s * b) ** 2) for s in (0.05, 0.10, 0.20)]
        print(f"   {lab:38s}" + "".join(f"{x:9,d}" for x in row))

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 8: Practice and a Pre-Registered Test. 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