5D Library › Liquidation Cascades, Order-Book Depth Depletion and Cointegrated Statistical Arbitrage · 中文

Chapter 3 Liquidation Cascades, Branching Processes and Hawkes Self-Exciting Point Processes

Events that trigger events

Earthquakes have aftershocks, and aftershocks have aftershocks of their own. The self-exciting point process Hawkes introduced in 1971 (Hawkes 1971) was designed for exactly this kind of “events triggering events”. Let λ(t)\lambda(t) be the event intensity at time tt (the expected number of events per unit time):

λ(t)=μ+∑ti<tαe−β(t−ti).\lambda(t) = \mu + \sum_{t_i < t} \alpha\, e^{-\beta (t – t_i)}.

μ\mu is the exogenous baseline intensity: events unrelated to the past, brought by outside news. Each event makes the intensity jump by α\alpha, after which the jump decays at rate β\beta.

Hawkes and Oakes gave its branching representation in 1974 (Hawkes and Oakes 1974): exogenous events arrive like “immigrants” at rate μ\mu, and every event, exogenous or triggered, independently produces on average n=α/βn = \alpha/\beta “offspring”, which produce offspring in turn. nn is the branching ratio. When n<1n < 1, each immigrant’s family has on average 1/(1−n)1/(1-n) events, the long-run average intensity is μ/(1−n)\mu/(1-n), and a fraction nn of all events is triggered, “endogenous”. n=1n = 1 is the critical point: every family still dies out with certainty, but its mean size diverges (1/(1−n)→∞1/(1-n) \to \infty); only when n>1n > 1 (supercritical) does a family have a positive probability of never dying out.

Simulate a Hawkes process with Ogata’s 1981 thinning algorithm (Ogata 1981): between events the intensity can only decay, so its current value is an upper bound until the next accepted event; draw a candidate time from it and accept with probability λ(t)/λ‾\lambda(t)/\bar\lambda. For four branching ratios, μ\mu is set so that the theoretical mean intensity is 1; the branching tree is also simulated directly to count family sizes.

Calculation

# Exponential-kernel Hawkes process by Ogata (1981) thinning; branching n = alpha/beta.
# Theory (n < 1): rate mu/(1-n), cluster mean 1/(1-n), long-window Fano 1/(1-n)^2.
import math, random

def ogata(mu, alpha, beta, T, rng):
    t, excite, ts = 0.0, 0.0, []          # excite = sum of alpha exp(-beta (t - t_i))
    while True:
        lam_bar = mu + excite
        w = rng.expovariate(lam_bar)
        t += w
        if t > T: return ts
        excite *= math.exp(-beta * w)
        if rng.random() * lam_bar <= mu + excite:
            ts.append(t); excite += alpha

def fano(ts, T, width):                   # variance / mean of counts in windows
    k = int(T // width); c = [0] * k
    for t in ts:
        j = int(t // width)
        if j < k: c[j] += 1
    m = sum(c) / k
    return sum((x - m) ** 2 for x in c) / k / m

def cluster_sizes(n, reps, rng):          # Galton-Watson tree, Poisson(n) children
    out = []
    for _ in range(reps):
        size, todo = 1, 1
        while todo and size < 10 ** 6:
            todo -= 1
            k, p, u = 0, math.exp(-n), rng.random()
            c = p
            while u > c:
                k += 1; p *= n / k; c += p
            size += k; todo += k
        out.append(size)
    return out

rng = random.Random(1971)
T, beta = 20000.0, 1.0
print("   n  | events  rate | Fano(100) sim / limit | cluster mean sim / theory"
      " | P(size>=100)")
for n in (0.0, 0.5, 0.8, 0.95):
    mu = 1.0 - n                          # keeps the theoretical mean rate at 1 per unit
    ts = ogata(mu, n * beta, beta, T, rng)
    cs = cluster_sizes(n, 20000, rng)
    big = sum(c >= 100 for c in cs) / len(cs)
    print(f" {n:4.2f} | {len(ts):6d}  {len(ts) / T:5.3f} |"
          f"    {fano(ts, T, 100.0):6.1f} / {1 / (1 - n) ** 2:5.0f}    |"
          f"     {sum(cs) / len(cs):6.2f} / {1 / (1 - n):6.2f}    |   {big:6.2%}")
#    n  | events  rate | Fano(100) sim / limit | cluster mean sim / theory | P(size>=100)
#  0.00 |  19986  0.999 |       0.9 /     1    |       1.00 /   1.00    |    0.00%
#  0.50 |  20107  1.005 |       4.3 /     4    |       2.00 /   2.00    |    0.00%
#  0.80 |  19776  0.989 |      28.3 /    25    |       4.96 /   5.00    |    0.14%
#  0.95 |  20173  1.009 |     306.2 /   400    |      20.23 /  20.00    |    4.08%

For all four branching ratios the mean intensity matches the theoretical value of 1, and the mean family size matches 1/(1−n)1/(1-n) (theory 20 at n=0.95n = 0.95, simulation 20.2). Beyond the averages, however, much changes. In windows of length 100, the variance-to-mean ratio of counts (the Fano factor) rises from about 1 for the Poisson process to about 28 at n=0.8n = 0.8 and over 300 at n=0.95n = 0.95 (the long-window limit is 1/(1−n)2=4001/(1-n)^2 = 400): events cluster more and more. The tail of family sizes thickens as well: at n=0.8n = 0.8 only 0.14 % of families reach 100 events, at n=0.95n = 0.95, 4 %. With the same mean intensity, a system near criticality occasionally erupts in enormous chains.

Note

Relation to Books 20 and 28. Book 20 used the sandpile model to discuss self-organised criticality and power laws; Book 28 discussed critical slowing down, early-warning signals and their limits. This chapter does not repeat them; it discusses only how the branching ratio of a point process is estimated and why it is hard to estimate well.

Estimating the branching ratio

The log-likelihood of an exponential-kernel Hawkes process can be computed recursively (Ozaki 1979 (Ozaki 1979)):

log⁡L=∑ilog⁡(μ+αAi)−μT−αβ∑i(1−e−β(T−ti)),Ai=e−β(ti−ti−1)(1+Ai−1).\log L = \sum_i \log\!\big(\mu + \alpha A_i\big) – \mu T – \frac{\alpha}{\beta}\sum_i \big(1 – e^{-\beta(T – t_i)}\big), \qquad A_i = e^{-\beta(t_i – t_{i-1})}(1 + A_{i-1}).

Maximise the likelihood with a home-made simplex (Nelder–Mead) search from the standard library. First fit genuine Hawkes data (n=0.7n = 0.7), then two kinds of Poisson data with no self-excitation at all: one with constant intensity, the other with intensity switching between 0.5 and 2.0.

Calculation

# Hawkes maximum likelihood (Ozaki 1979 recursion), Nelder-Mead over
# (log mu, logit n, log beta). Fitted to Hawkes data and to Poisson data with no
# self-excitation, constant or switching between rates 0.5 and 2.0.
import math, random

def ogata(mu, alpha, beta, T, rng):
    t, ex, ts = 0.0, 0.0, []
    while True:
        lb = mu + ex; w = rng.expovariate(lb); t += w
        if t > T: return ts
        ex *= math.exp(-beta * w)
        if rng.random() * lb <= mu + ex: ts.append(t); ex += alpha

def switching_poisson(rates, seg, T, rng):
    t, ts = 0.0, []
    while t < T:
        k = int(t // seg); end = (k + 1) * seg
        w = rng.expovariate(rates[k % len(rates)])
        if t + w >= end: t = end; continue  # memoryless: restart at the regime boundary
        t += w
        if t < T: ts.append(t)
    return ts

def loglik(p, ts, T):
    mu, n, beta = math.exp(p[0]), 1 / (1 + math.exp(-p[1])), math.exp(p[2])
    alpha, A, prev, s = n * beta, 0.0, None, 0.0
    for t in ts:
        if prev is not None: A = math.exp(-beta * (t - prev)) * (1 + A)
        s += math.log(mu + alpha * A); prev = t
    comp = mu * T + n * sum(1 - math.exp(-beta * (T - t)) for t in ts)
    return s - comp

def nelder_mead(f, x0, step=0.5, iters=250):
    pts = [list(x0)] + [[x + (step if i == j else 0) for j, x in enumerate(x0)]
                        for i in range(len(x0))]
    vals = [f(p) for p in pts]
    for _ in range(iters):
        order = sorted(range(len(pts)), key=lambda i: vals[i])
        pts = [pts[i] for i in order]; vals = [vals[i] for i in order]
        c = [sum(p[j] for p in pts[:-1]) / (len(pts) - 1) for j in range(len(x0))]
        def at(k): return [c[j] + k * (pts[-1][j] - c[j]) for j in range(len(x0))]
        r = at(-1); fr = f(r)
        if fr < vals[0]:
            e = at(-2); fe = f(e)
            pts[-1], vals[-1] = (e, fe) if fe < fr else (r, fr)
        elif fr < vals[-2]: pts[-1], vals[-1] = r, fr
        else:
            k = at(0.5); fk = f(k)
            if fk < vals[-1]: pts[-1], vals[-1] = k, fk
            else:
                pts = [pts[0]] + [[(a + b) / 2 for a, b in zip(pts[0], p)]
                                  for p in pts[1:]]
                vals = [vals[0]] + [f(p) for p in pts[1:]]
    return pts[0]

def fit(ts, T):
    p = nelder_mead(lambda q: -loglik(q, ts, T), [math.log(len(ts) / T / 2), 0.0, 0.0])
    return math.exp(p[0]), 1 / (1 + math.exp(-p[1])), math.exp(p[2])

def row(label, ts, T):
    mu, n, b = fit(ts, T)
    print(f"{label:38s} | {len(ts):6d} |   {mu:5.3f}  {n:5.2f}  {b:6.3f}")

rng = random.Random(1979)
T = 4000.0
print("data                                   | events | fitted mu     n    beta")
for rep in range(3):
    row(f"Hawkes, mu 0.3, n 0.70, beta 1.0 (#{rep + 1})", ogata(0.3, 0.7, 1.0, T, rng), T)
row("Poisson, constant rate 1.0", switching_poisson((1.0,), T, T, rng), T)
for seg in (400.0, 40.0):
    for rep in range(2):
        row(f"Poisson, 0.5/2.0, regimes of {seg:3.0f} (#{rep + 1})",
            switching_poisson((0.5, 2.0), seg, T, rng), T)
# data                                   | events | fitted mu     n    beta
# Hawkes, mu 0.3, n 0.70, beta 1.0 (#1)  |   4104 |   0.298   0.71   0.946
# Hawkes, mu 0.3, n 0.70, beta 1.0 (#2)  |   3803 |   0.284   0.70   0.997
# Hawkes, mu 0.3, n 0.70, beta 1.0 (#3)  |   4290 |   0.325   0.70   1.052
# Poisson, constant rate 1.0             |   4102 |   1.011   0.02   0.001
# Poisson, 0.5/2.0, regimes of 400 (#1)  |   5062 |   0.099   0.93   0.076
# Poisson, 0.5/2.0, regimes of 400 (#2)  |   4877 |   0.103   0.92   0.074
# Poisson, 0.5/2.0, regimes of  40 (#1)  |   5049 |   0.297   0.77   0.297
# Poisson, 0.5/2.0, regimes of  40 (#2)  |   5006 |   0.308   0.75   0.298

When the data really are a Hawkes process the estimates are good: three simulations give branching ratios of 0.70 to 0.71. Constant-intensity Poisson data give 0.02, close to the true 0. But when the baseline switches between two levels (segments of 400 time units), the fitted branching ratio is as high as 0.92 to 0.93, with a decay rate of only about 0.07, even though no event in the data triggers any other: the model imitates the regime switches with a slowly decaying “self-excitation”. With faster switching (segments of 40), the fitted ratio is still 0.75 to 0.77.

Evidence

How close are markets to criticality? Filimonov and Sornette in 2012 fitted an exponential-kernel Hawkes model to mid-price changes of the US E-mini S&P 500 futures from 1998 to 2010 and found that endogeneity rose markedly: in 1998 about 70 % of price changes could be explained by exogenous information, after 2007 less than 30 % (Filimonov and Sornette 2012), that is, a branching ratio rising from about 0.3 to above 0.7. Hardiman, Bercot and Bouchaud in 2013 used a power-law kernel on the same market and found that the integral of the kernel was close to 1 and nearly constant from 1998 to 2011, concluding that the market had stayed close to criticality throughout; they argued that fitting a short-memory exponential kernel to a critical power-law process yields a branching ratio that is too low and rises over time (Hardiman et al. 2013). Filimonov and Sornette replied in 2015 that outliers, intraday seasonality, overnight trading and non-stationary parameters systematically push estimates towards 1, and that calibrating on mixtures of Poisson processes with regime shifts produces spurious critical values, so the conclusion that markets are at criticality does not stand (Filimonov and Sornette 2015). For a review see Bacry, Mastromatteo and Muzy (Bacry et al. 2015).

The dispute is unresolved, but the program shows its crux: the estimated branching ratio is extremely sensitive to model specification; kernel shape, time window and a non-stationary baseline can each move the estimate for the same data from 0.3 to near 1. Any claim that “the branching ratio is X, so a crash is coming” should first be asked whether baseline changes have been mistaken for self-excitation.

The author’s derivation: the effective branching ratio of a liquidation cascade

The toy model of Chapter 2 can be rewritten in the language of branching. Let liquidation prices below the current price be spread with density ρ\rho (liquidation notional per 1 % price band) and let the bid depth be dd (selling needed per 1 % fall). An initial fall of s%s\% triggers ρs\rho s of liquidation selling, which pushes the price down a further ρs/d=ns%\rho s/d = ns\%, which triggers n2s%n^2 s\%, and so on, where

neff=ρd.n_{\text{eff}} = \frac{\rho}{d}.

If neff<1n_{\text{eff}} < 1 the total fall is the geometric series s/(1−neff)s/(1 – n_{\text{eff}}); if neff≥1n_{\text{eff}} \ge 1 the series diverges and the fall continues until the band of liquidation prices ends.

First check the geometric series on a uniform band of liquidation prices (0 to 20 % below the current price); then compute, for the “aggressive” leverage mix of Chapter 2, how the density of liquidation prices is distributed over price levels and what neffn_{\text{eff}} results at different depths.

Calculation

The author’s derivation.

# Author's derivation: effective branching ratio n = rho / d of a liquidation cascade;
# total fall s / (1 - n) if n < 1, otherwise the whole band of liquidation prices.
def cascade(s, rho, d, band=20.0, step=1e-3):
    fall, sold_to = s, 0.0                # sold_to: depth of band already liquidated (%)
    while True:
        reach = min(fall, band)
        new = rho * (reach - sold_to)
        if new <= step * rho: return fall
        sold_to = reach; fall += new / d

print("uniform band of liquidation prices 0-20 % below, shock s = 1 %")
print("   n = rho/d | simulated fall | s / (1 - n) for an endless band")
for n in (0.0, 0.5, 0.8, 0.9, 0.99, 1.0, 1.2):
    sim = cascade(1.0, 100 * n, 100.0)
    th = f"{1 / (1 - n):10.1f} %" if n < 1 else "  diverges"
    print(f"     {n:4.2f}    | {sim:11.1f} %  | {th}")
# Aggressive mix of Chapter 2: entries uniform on 97-103 -> liquidation prices uniform on
# [97, 103] (1 - 1/L) / (1 - m); shares of 2,000 units of notional, m = 0.5 %.
MIX = [(5, .2), (10, .3), (20, .3), (25, .1), (50, .1)]
m, TOT = 0.005, 2000.0

def rho(x):                               # notional with liquidation price in [x - 1, x)
    out = 0.0
    for L, w in MIX:
        lo = 97 * (1 - 1 / L) / (1 - m); hi = min(103 * (1 - 1 / L) / (1 - m), 100)
        if hi <= lo: continue
        ov = max(0.0, min(hi, x) - max(lo, x - 1))
        out += TOT * w * ov / (103 * (1 - 1 / L) / (1 - m) - lo)
    return out

print("price level | rho (units per 1 %) | n_eff at depth d = 400 | d = 200 | d = 100")
for x in range(100, 76, -2):
    r = rho(x)
    print(f"  {x:5d}     |       {r:6.0f}        |        {r / 400:5.2f}"
          f"           |  {r / 200:5.2f}  |  {r / 100:5.2f}")
# uniform band of liquidation prices 0-20 % below, shock s = 1 %
#    n = rho/d | simulated fall | s / (1 - n) for an endless band
#      0.00    |         1.0 %  |        1.0 %
#      0.50    |         2.0 %  |        2.0 %
#      0.80    |         5.0 %  |        5.0 %
#      0.90    |        10.0 %  |       10.0 %
#      0.99    |        20.8 %  |      100.0 %
#      1.00    |        21.0 %  |   diverges
#      1.20    |        25.0 %  |   diverges
# price level | rho (units per 1 %) | n_eff at depth d = 400 | d = 200 | d = 100
#     100     |           47        |         0.12           |   0.23  |   0.47
#      98     |          173        |         0.43           |   0.87  |   1.73
#      96     |          155        |         0.39           |   0.77  |   1.55
#      94     |          137        |         0.34           |   0.69  |   1.37
#      92     |          111        |         0.28           |   0.55  |   1.11
#      90     |          111        |         0.28           |   0.55  |   1.11
#      88     |           29        |         0.07           |   0.14  |   0.29
#      86     |            0        |         0.00           |   0.00  |   0.00
#      84     |            0        |         0.00           |   0.00  |   0.00
#      82     |           83        |         0.21           |   0.41  |   0.83
#      80     |           83        |         0.21           |   0.41  |   0.83
#      78     |            1        |         0.00           |   0.00  |   0.01
Left: the effective branching ratio by price level for the aggressive leverage mix; liquidation prices of the 10- to 50-times positions crowd between 88 and 100, those of the 5-times positions between 78 and 83, with a gap in between. At depth 100 the effective branching ratio exceeds 1 over most of the range below the current price. Right: the final fall after initial shocks of 2 % and 5 % at different depths; the fall grows sharply when depth drops below about 200.

The geometric series matches the simulation exactly: at n=0.5n = 0.5 the fall doubles, at 0.9 it is amplified tenfold. At n=0.99n = 0.99 an endless band would in theory amplify the fall a hundredfold, but the band of liquidation prices is only 20 % deep, so the fall stops at 20.8 %; at n≥1n \ge 1 it runs through the whole band. In the aggressive mix, liquidation prices are densest around 97 to 98 (about 173 units per 1 %); at depth 200 the effective branching ratio peaks at about 0.87, at depth 100 at 1.73. This explains Chapter 2’s result: at depth 100 and a 2 % shock the cascade burned down to about 83 and stopped, because there are no liquidation prices at all between 83 and 88 (the gap between the 10-times and 5-times positions), and the gap acted as a “firebreak”; a 5 % shock carried the price straight across the gap into the 5-times positions, for a final fall of 23.3 %.

Note

This is an analogy, not the same quantity. The branching ratio of a Hawkes process is defined in time: how many events one event triggers on average in the future. neffn_{\text{eff}} here is defined in price: how much further fall one unit of fall triggers on average through liquidations. The two share a mathematical structure (geometric series, critical value 1), but neffn_{\text{eff}} varies with the price level and rests on the strong assumption that depth is not replenished during the cascade. In reality depth may be withdrawn in a panic (raising neffn_{\text{eff}}) or replenished by bargain hunters (lowering it).

Hypothesis · not established

The locality of the effective branching ratio (not established). The author’s hypothesis is that the size of a liquidation cascade is set not by the market-wide average leverage but by the local profile of neffn_{\text{eff}} below the current price, with gaps between liquidation prices acting as firebreaks. Falsifiable prediction: in markets with data on liquidation prices by level, falls after shocks should slow markedly where the neffn_{\text{eff}} profile has gaps; if the points where falls stop bear no relation to gaps in the profile, the hypothesis is wrong.

Chapter summary

The Hawkes process describes how far events trigger events through the branching ratio nn: when n<1n < 1 the mean intensity is μ/(1−n)\mu/(1-n), and as nn approaches 1 events cluster strongly with occasional huge chains. The branching ratio can be estimated by recursive likelihood but is extremely sensitive to model specification: data without self-excitation, only with baseline switches, can be fitted with a branching ratio of 0.92, which is the heart of the dispute over whether markets are at criticality. The author writes liquidation cascades as an effective branching ratio in price, neff=ρ/dn_{\text{eff}} = \rho/d, set jointly by the leverage distribution and depth, and local in character. The next chapter turns to the other side of trading: mean reversion.

References

Bacry, Emmanuel, Iacopo Mastromatteo, and Jean-François Muzy. 2015. “Hawkes Processes in Finance.” Market Microstructure and Liquidity 1 (1): 1550005. https://doi.org/10.1142/S2382626615500057.
Filimonov, Vladimir, and Didier Sornette. 2012. “Quantifying Reflexivity in Financial Markets: Toward a Prediction of Flash Crashes.” Physical Review E 85 (5): 056108. https://doi.org/10.1103/PhysRevE.85.056108.
Filimonov, Vladimir, and Didier Sornette. 2015. “Apparent Criticality and Calibration Issues in the Hawkes Self-Excited Point Process Model: Application to High-Frequency Financial Data.” Quantitative Finance 15 (8): 1293–314. https://doi.org/10.1080/14697688.2015.1032544.
Hardiman, Stephen J., Nicolas Bercot, and Jean-Philippe Bouchaud. 2013. “Critical Reflexivity in Financial Markets: A Hawkes Process Analysis.” European Physical Journal B 86: 442. https://doi.org/10.1140/epjb/e2013-40107-3.
Hawkes, Alan G. 1971. “Spectra of Some Self-Exciting and Mutually Exciting Point Processes.” Biometrika 58 (1): 83–90. https://doi.org/10.1093/biomet/58.1.83.
Hawkes, Alan G., and David Oakes. 1974. “A Cluster Process Representation of a Self-Exciting Process.” Journal of Applied Probability 11 (3): 493–503.
Ogata, Yosihiko. 1981. “On Lewis’ Simulation Method for Point Processes.” IEEE Transactions on Information Theory 27 (1): 23–31. https://doi.org/10.1109/TIT.1981.1056305.
Ozaki, T. 1979. “Maximum Likelihood Estimation of Hawkes’ Self-Exciting Point Processes.” Annals of the Institute of Statistical Mathematics 31 (1): 145–55. https://doi.org/10.1007/BF02480272.

Fan, Y. (2026). Liquidation Cascades, Order-Book Depth Depletion and Cointegrated Statistical Arbitrage: Ornstein-Uhlenbeck Processes and Kalman-Filter Dynamic Hedging [高杠杆衍生品清算瀑布、订单簿深度衰竭与协整统计套利] (Version 1.0.0). 5D Library. https://doi.org/10.5281/zenodo.23796776 · Licensed under Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0).