5D Library › 高频限价订单簿微观结构、霍克斯自激点过程与逆向选择毒流 · English

第八章 实践与预注册检验

注

本章的核查表与实验方案用于研究与自我检查,不是投资或交易建议。 核查表不能告诉你该怎样报价或交易,只能帮助你在做决定之前把假设写清楚。书中的交易日、订单、成交与策略都是虚构或模拟的;任何真实的交易都可能亏损。

第一部分 四步核查表

第一至六章可以浓缩为一份四步核查表,用于审视一个做市或执行的交易日。表中的界限(例如「已实现价差的均值加两个标准误仍小于零时标记」)是使用者应当事先书面写定的规则的例子,不是推荐的数值。

  1. 逆向选择。 按成交方向分别计算固定跨度(例如 60 秒)的已实现价差与价格冲击。某一侧的已实现价差是否显著为负?两侧是否明显不对称(第一、四章)?
  2. 订单流。 某一方向市价单的到达强度是否显著高于参照时段?到达是否成簇(法诺因子)?同时看波动率与成交量是否也在变化,因为任何基于成交的毒性指标都可能机械地随它们变化(第三、四章)。
  3. 库存。 把损益分为价差收入与库存损益两部分。库存损失是否超过价差收入?最大库存是否超过限额(第二章)?
  4. 执行。 本机构自己的母单,执行缺口与事前估计(期望与标准差)相比如何?差异是否超过事先写定的倍数(第六章)?

下面的程序把核查表用于一个虚构的交易日:23,400 个一秒钟步长,做市商在中间价上下各 2 个最小变动单位报价,并按库存偏置;最后 30 分钟有一个知情卖家,每秒以 0.05 的概率发出 100 股的市价卖单,每笔之后中间价永久下跌 1.5 个单位;同一天,本机构还按每 60 秒一片的节奏卖出一笔 30,000 股的母单。

推导

# The four-step check applied to a FICTIONAL market-making day (23,400 one-second steps,
# mid starts at 100.00, tick 0.01, public noise 0.6 tick per second). The maker quotes
# +-2 ticks around the mid, skewed by 0.2 tick per 100 shares of inventory, 100 shares
# per fill. From 15:30 (step 21,600) an informed seller sends extra 100-share market
# sells at rate 0.05 per second, each followed by a permanent 1.5-tick fall of the mid.
# The desk also sells a parent order of 30,000 shares in 300 slices, one per 60 s, from
# 10:00, each crossing the spread (half-spread 1 tick) and lowering the mid 0.1 tick.
# Flag thresholds are written down BEFORE looking at the day.
import math, random, statistics

TICK, STEPS, TOX = 0.01, 23_400, 21_600

def day(rng):
    mid, q, fills, mids, inv, slices, sells = 100.0, 0, [], [], [], [], []
    for t in range(STEPS):
        mid += 0.6 * TICK * rng.gauss(0, 1); mids.append(mid)
        skew = 0.2 * TICK * q / 100
        bid, ask = mid - 2 * TICK - skew, mid + 2 * TICK - skew
        lam_b = 0.10 * math.exp(-(mid - bid) / TICK + 2)       # noise sells hit our bid
        lam_a = 0.10 * math.exp(-(ask - mid) / TICK + 2)       # noise buys lift our ask
        if rng.random() < lam_b:
            q += 100; fills.append((t, +1, bid)); sells.append(t)
        if rng.random() < lam_a:
            q -= 100; fills.append((t, -1, ask))
        if t >= TOX and rng.random() < 0.05:                    # informed seller
            q += 100; fills.append((t, +1, bid)); sells.append(t); mid -= 1.5 * TICK
        if 1800 <= t < 1800 + 300 * 60 and (t - 1800) % 60 == 0:
            slices.append((t, mid, mid - TICK)); mid -= 0.1 * TICK  # desk's own slice
        inv.append(q)
    return fills, mids, inv, slices, sells

def markout(fills, mids, h):
    rs, pi = [], []
    for t, d, p in fills:
        D = -d                                    # the taker's direction (+1 = buy)
        m0, m1 = mids[t], mids[min(t + h, STEPS - 1)]
        rs.append(2 * D * (p - m1) / TICK); pi.append(2 * D * (m1 - m0) / TICK)
    return rs, pi

if __name__ == "__main__":
    rng = random.Random(45); fills, mids, inv, slices, sells = day(rng)
    print(f"fictional day: {len(fills):,} fills; close {mids[-1]:.2f};"
          f" final inventory {inv[-1]:+,} shares")
    print("1 adverse selection: 60-s realized spread by side, ticks per fill"
          "\n  (flag if mean + 2 s.e. < 0)")
    for lab, lo, hi in (("09:30-15:30", 0, TOX), ("15:30-16:00", TOX, STEPS)):
        for side, nm in ((+1, "our bid hit"), (-1, "our ask hit")):
            rs, pi = markout([f for f in fills if lo <= f[0] < hi and f[1] == side],
                             mids, 60)
            m, se = statistics.fmean(rs), statistics.stdev(rs) / math.sqrt(len(rs))
            print(f"   {lab} {nm}: {len(rs):4d} fills, realized {m:+6.2f} (s.e. {se:.2f})"
                  f" -> {'FLAG' if m + 2 * se < 0 else 'ok'}")
    dr = (mids[TOX - 1] - mids[0]) / TICK
    print(f"   mid drift 09:30-15:30 {dr:+.0f} ticks ({dr / 360:+.2f} per 60 s);"
          f" desk's own slices {-0.1 * len(slices):+.0f}")
    print("2 flow: market sells per minute, last 30 min against 09:30-15:00"
          " (flag if z > 3)")
    per = [0] * (STEPS // 60)
    for t in sells:
        per[t // 60] += 1
    ref, now = per[:330], per[360:]
    m, sd = statistics.fmean(ref), statistics.stdev(ref)
    z = (statistics.fmean(now) - m) / (sd / math.sqrt(len(now)))
    fano = statistics.variance(ref) / m
    print(f"   reference {m:.2f} (Fano factor {fano:.2f}), now"
          f" {statistics.fmean(now):.2f}, z = {z:+.1f} -> {'FLAG' if z > 3 else 'ok'}")
    v1 = statistics.pstdev(b - a for a, b in zip(mids[:TOX], mids[1:TOX])) / TICK
    v2 = statistics.pstdev(b - a for a, b in zip(mids[TOX:], mids[TOX + 1:])) / TICK
    print(f"   read with: 1-s volatility {v1:.2f} -> {v2:.2f} ticks")
    print("3 inventory: spread capture against inventory P&L"
          " (flag if inventory loss > capture)")
    for lab, lo, hi in (("09:30-15:30", 0, TOX), ("15:30-16:00", TOX, STEPS - 1)):
        cap = sum(d * (mids[t] - p) * 100 for t, d, p in fills if lo <= t < hi)
        invp = sum(inv[t] * (mids[t + 1] - mids[t]) for t in range(lo, hi))
        print(f"   {lab}: capture ${cap:,.0f}, inventory ${invp:+,.0f},"
              f" max |q| {max(abs(x) for x in inv[lo:hi]):,}"
              f" -> {'FLAG' if -invp > cap else 'ok'}")
    print("4 execution: parent sell order against its pre-trade estimate"
          " (flag if |z| > 2)")
    arr, n = slices[0][1], 100
    sf = sum(n * (arr - px) for _, _, px in slices)
    spr = sum(n * (m - px) for _, m, px in slices)
    pre = 300 * n * TICK + n * 0.1 * TICK * 299 * 300 / 2
    sd = 0.6 * TICK * math.sqrt(sum((n * (300 - k)) ** 2 * 60 for k in range(1, 301)))
    z = (sf - pre) / sd
    print(f"   shortfall ${sf:,.0f} (spread ${spr:,.0f}); estimate ${pre:,.0f},"
          f" sd ${sd:,.0f}; z = {z:+.2f} -> {'FLAG' if abs(z) > 2 else 'ok'}")
# fictional day: 5,004 fills; close 96.58; final inventory +0 shares
# 1 adverse selection: 60-s realized spread by side, ticks per fill
#   (flag if mean + 2 s.e. < 0)
#    09:30-15:30 our bid hit: 2257 fills, realized  +2.67 (s.e. 0.19) -> ok
#    09:30-15:30 our ask hit: 2256 fills, realized  +4.99 (s.e. 0.19) -> ok
#    15:30-16:00 our bid hit:  245 fills, realized  -7.67 (s.e. 0.65) -> FLAG
#    15:30-16:00 our ask hit:  246 fills, realized +14.49 (s.e. 0.63) -> ok
#    mid drift 09:30-15:30 -181 ticks (-0.50 per 60 s); desk's own slices -30
# 2 flow: market sells per minute, last 30 min against 09:30-15:00 (flag if z > 3)
#    reference 6.27 (Fano factor 0.60), now 8.17, z = +5.4 -> FLAG
#    read with: 1-s volatility 0.60 -> 0.69 ticks
# 3 inventory: spread capture against inventory P&L (flag if inventory loss > capture)
#    09:30-15:30: capture $8,617, inventory $+118, max |q| 600 -> ok
#    15:30-16:00: capture $938, inventory $-276, max |q| 600 -> ok
# 4 execution: parent sell order against its pre-trade estimate (flag if |z| > 2)
#    shortfall $26,002 (spread $300); estimate $4,785, sd $13,908; z = +1.53 -> ok

第一步在最后 30 分钟标记:我们的买价被吃时,60 秒已实现价差为 −7.67 个单位(标准误 0.65),而卖价被吃时为 +14.49。只看两侧合计会得出「一切正常」的结论,因为偏置报价让做市商在价格下跌中卖出了更多,卖价一侧的盈利掩盖了买价一侧的逆向选择;这说明逆向选择应当分方向看。前六个小时两侧都为正(+2.67 与 +4.99);两侧的差异来自当天中间价的总体下行(六小时共 181 个单位,每 60 秒平均约 0.5 个单位;其中 30 个单位、约六分之一是本机构自己的卖出母单造成的)。第二步也标记:最后 30 分钟每分钟的市价卖单从参照时段的 6.27 笔升到 8.17 笔(z = +5.4);同时一秒钟波动率从 0.60 升到 0.69 个单位,所以按第四章的讨论,这一信号要与波动率一起解读。参照时段的法诺因子为 0.60,低于 1,因为库存偏置使卖单到达对库存产生负反馈。第三步没有标记:最后 30 分钟价差收入为 938 美元,库存损失只有 276 美元,最大库存 600 股,没有超过 2,000 股的限额——偏置报价使库存很快回到零附近。第四步也没有标记:母单的执行缺口为 26,002 美元,事前估计为 4,785 美元、标准差 13,908 美元,z = +1.53,在两倍标准差之内。这个例子的教训是:四步各看一个侧面,单看库存与执行,这一天并无异常;逆向选择只有在分方向的已实现价差中才清楚地显示出来。

第二部分 预注册的模拟撮合实验

问题与设计选择

在一个由独立第三方构建、事先冻结的模拟限价订单簿中,混入脉冲式的知情订单流(「毒性脉冲」)时,按库存动态偏置报价的阿韦拉内达—斯托伊科夫策略,其终端净值的跨会话夏普比率是否高于固定对称价差的策略,且差别至少达到最小关注效应?

作者的框架提出在「模拟限价订单簿双盲撮合实验」中比较这两种策略对「终端净值夏普比率与最大库存回撤」的影响。本书照写比较组,并作三点设计选择。第一,用模拟而不是真实交易:比较的是报价规则,模拟可以让两种策略面对完全相同的订单流与脉冲(配对),因果识别清楚,也不需要任何人承担资金风险;代价是结论只适用于模拟器,见下文「不能说明什么」。第二,只设一项主要结局:选跨会话夏普比率之差,最大库存与会话内回撤作次要结局。理由是,夏普比率同时反映收益与风险,与第二章假说的表述直接对应;最大回撤是整条路径的单一统计量,第 38 本第八章已说明它几乎没有统计把握度;最大库存是风险的来源而不是结果,可以作为机制的旁证。第三,由独立第三方实施:模拟器、脉冲的时间与方向、随机种子都由与作者无关的研究者生成并封存,作者只提交两种策略的代码。

需要说明一点:夏普比率不是阿韦拉内达—斯托伊科夫模型的目标函数(它最大化的是期望指数效用,第二章已指出二者可能给出不同的排序)。本方案检验的是作者框架提出的问题,即「哪种报价规则的风险调整后表现更好」,而不是「哪种规则更符合它自己的最优化目标」。

方案

要素 规定
模拟器 由第三方选用并冻结的多主体限价订单簿模拟器(例如 ABIDES 一类的开源离散事件模拟器 (Byrd et al. 2020)),包含噪声交易者、其他做市商与按价格—时间优先撮合的交易所;配置文件与版本号在登记方案时公开
毒性脉冲 由第三方按登记的分布生成:每个会话以概率 1/2 出现一次脉冲,持续时间、方向与强度在登记的范围内随机;脉冲期间的知情主体只在有利可图时吃单;生成脚本公开,种子封存至结果锁定
两种策略 X:阿韦拉内达—斯托伊科夫库存偏置报价(γ=0.1\gamma = 0.1,原文公式,会话长度为 TT);Y:围绕中间价的固定对称报价,价差等于 X 在另一组校准会话中的平均价差。两者的单笔数量、库存上限与撤单延迟相同
配对与设盲 每个会话的同一组种子分别运行 X 与 Y;策略代码以哈希值登记,由第三方随机标为「甲 / 乙」,运行与分析人员在结果锁定前不知道对应关系(双盲);作者不接触种子与脉冲时间表
主要结局 D=SRX−SRYD = \mathrm{SR}_X – \mathrm{SR}_Y,SR 为终端净值(会话结束时按中间价计的盈亏)跨会话的均值除以标准差;95% 置信区间用按会话配对的自助法(10,000 次重抽)计算
预先规定的限定语 X 的平均终端净值是否比 Y 低 5% 以上;若是,结论后附「夏普比率较高以平均收益较低为代价」
次要结局 平均终端净值与其标准差;会话内最大绝对库存;会话内按盯市计算的最大回撤;脉冲期间的损益;成交率;有脉冲与无脉冲会话分别的夏普比率;正态理论(乔布森—科尔基、梅梅尔)标准误 (Jobson and Korkie 1981; Memmel 2003) 与稳健检验 (Ledoit and Wolf 2008) 作为对照;均为描述性或探索性分析

主要结局只设一项,选「夏普比率之差」。夏普比率的估计量有已知的偏差,在收益非正态、序列相关时标准误公式需要修正 (Lo 2002);乔布森与科尔基的两组夏普比率比较检验经梅梅尔修正后,在独立同分布的二元正态假设下的渐近方差为 2(1−ρ)+12(SRX2+SRY2)−ρ2SRXSRY2(1-\rho) + \tfrac12(\mathrm{SR}_X^2 + \mathrm{SR}_Y^2) – \rho^2\,\mathrm{SR}_X\mathrm{SR}_Y;莱多伊特与沃尔夫指出这一公式依赖正态假设,建议用自助法 (Ledoit and Wolf 2008)。本方案以配对自助法为准,正态公式只作对照。

防止数据窥探

只有一组预先固定的策略参数与一项主要结局,作者不在独立模拟器上调参;模拟器配置、脉冲生成脚本、策略代码与分析代码在运行之前公开登记,代码的哈希值随方案一起登记 (Nosek et al. 2018);全部运行与分析由第三方执行;次要与探索性结果明确标注,不能用来替代主要结论。第 33 本讨论过这些做法的统计原理。

样本量

样本量需要对效应与方差作出假设。本书用一个试点环境来设定这些假设:它是第二章阿韦拉内达—斯托伊科夫模拟加上毒性脉冲的作者自己的玩具模型,不是实验将要使用的模拟器。

推导

# 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))
# 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

试点环境中(4,000 个配对会话),X 的夏普比率为 9.06(平均终端净值 64.5、标准差 7.1),Y 为 3.09(63.6、20.6),配对净值的相关系数 0.33,差为 +5.97;X 的平均最大库存 4.4,Y 为 11.6。Y 的平均净值在无脉冲的会话中为 68.4,在有脉冲的会话中为 59.0;X 分别为 65.0 与 64.1。这些数字是规划假设,不是证据:试点环境由作者构建,在其中库存偏置天然有利;独立模拟器中的真实差别可能小得多,甚至为零。

最小关注效应取 Y 夏普比率的 10%,即 0.31:小于这个改善,就不值得为库存偏置报价增加的复杂性改变做法。在双侧 α=0.05\alpha = 0.05、90% 把握度下,正态理论公式(渐近方差 44.0)需要 4,844 个配对会话;但用试点会话自助法估计的标准误比正态理论大(0.121 对 0.095),因为终端净值在有脉冲时明显偏斜。按自助法标准误换算,需要 7,779 个配对会话,考虑 10% 的运行失败并取整,计划 8,600 个。敏感性表显示,最小关注效应若取 5%,需要 31,114 个;方差若比估计高 50%,10% 的最小关注效应需要 11,668 个。模拟会话的成本远低于真实交易,所以样本量本身不是瓶颈,瓶颈是事先锁定设定。

按第 33 本第六章的结果,「90% 把握度」指的是在真实效应恰好等于最小关注效应时,得出「X 的夏普比率较高」(置信区间下限大于 0)这类结论的概率约为 90%;在这种情况下,最强的结论「至少高出最小关注效应」只有约 2.5% 的机会出现。

判定规则

推导

# Decision rule, fixed before the third party runs the locked simulation. D = SR_X - SR_Y,
# the difference in cross-session Sharpe ratios of terminal P&L (X = inventory-aware AS
# quotes, Y = fixed symmetric quotes), with a 95 % CI from a paired bootstrap over
# sessions (10,000 resamples). SESOI 0.31. Gates, checked first: more than 5 % of
# sessions failed or truncated; the independent re-run disagreeing on more than 0.1 % of
# sessions; arm labels revealed before the results were locked -> NOT INTERPRETABLE.
# Pre-specified qualifier: whether X's mean P&L is more than 5 % below Y's.
SESOI = 0.31

def verdict(d, lo, hi, mean_ratio, failed=0.01, mismatch=0.0, unblinded=False):
    for bad, why in ((failed > 0.05, f"{failed:.0%} of sessions failed (limit 5 %)"),
                     (mismatch > 0.001, f"re-run differs on {mismatch:.2%}"
                                        " (limit 0.1 %)"),
                     (unblinded, "labels revealed before lock")):
        if bad:
            return f"D = {d:+.2f}: NOT INTERPRETABLE - {why}"
    if lo >= SESOI:   v = "X's Sharpe ratio is higher by at least the SESOI"
    elif lo > 0:      v = "X's Sharpe ratio is higher; not shown to reach the SESOI"
    elif hi < 0:      v = "Y's Sharpe ratio is higher"
    elif lo >= -SESOI and hi <= SESOI: v = "no difference worth acting on"
    else:             v = "unclear: the interval is too wide to decide"
    if mean_ratio < 0.95:
        v += f"\n    qualifier: X's mean P&L is {1 - mean_ratio:.0%} below Y's mean P&L"
    return f"D = {d:+.2f} ({lo:+.2f} to {hi:+.2f}): {v}"

for case in ((5.10, 4.80, 5.40, 1.02), (0.40, 0.12, 0.68, 1.00),
             (0.05, -0.20, 0.30, 0.99), (-0.50, -0.80, -0.20, 1.05),
             (0.20, -0.45, 0.85, 1.00), (1.20, 0.90, 1.50, 0.88),
             (2.00, 1.70, 2.30, 1.00, 0.08), (2.00, 1.70, 2.30, 1.00, 0.01, 0.004)):
    print(verdict(*case))
print("secondary outcomes (mean P&L, P&L sd, max |inventory|, intra-session drawdown,")
print("  P&L inside pulses, fill rates) are reported with intervals; they never decide")
print("  the verdict")
# D = +5.10 (+4.80 to +5.40): X's Sharpe ratio is higher by at least the SESOI
# D = +0.40 (+0.12 to +0.68): X's Sharpe ratio is higher; not shown to reach the SESOI
# D = +0.05 (-0.20 to +0.30): no difference worth acting on
# D = -0.50 (-0.80 to -0.20): Y's Sharpe ratio is higher
# D = +0.20 (-0.45 to +0.85): unclear: the interval is too wide to decide
# D = +1.20 (+0.90 to +1.50): X's Sharpe ratio is higher by at least the SESOI
#     qualifier: X's mean P&L is 12% below Y's mean P&L
# D = +2.00: NOT INTERPRETABLE - 8% of sessions failed (limit 5 %)
# D = +2.00: NOT INTERPRETABLE - re-run differs on 0.40% (limit 0.1 %)
# secondary outcomes (mean P&L, P&L sd, max |inventory|, intra-session drawdown,
#   P&L inside pulses, fill rates) are reported with intervals; they never decide
#   the verdict

示例结果是编造的。前置条件中任何一项不满足(超过 5% 的会话失败或被截断、独立重跑与登记代码的结果在超过 0.1% 的会话上不一致、结果锁定前标签被揭示),无论主要结局如何,报告都写「不可解释」。只有当置信区间下限不低于 0.31 时,报告才写「X 的夏普比率至少高出最小关注效应」;下限高于 0 但低于 0.31 时写「X 较高,但幅度未确定」;上限低于 0 时写「Y 较高」;区间落在 ±0.31 之内时写「没有值得据此改变做法的差别」;其余情形写「无法判断」。限定语不改变结论的类别,只是附在后面:例如第六个示例中,X 的平均净值比 Y 低 12%,报告必须同时写明这一点。

这项实验不能说明什么

第一,模拟器不是真实市场:结论只对模拟器中的噪声交易者、其他做市商与知情主体的设定成立,真实的知情交易可能更隐蔽、更持久,也可能与库存偏置相互作用。第二,毒性脉冲的设计决定了结果;方案登记了脉冲的分布,但无法覆盖所有形式的逆向选择。第三,它只检验一组参数(γ=0.1\gamma = 0.1、一种会话长度、一种价差匹配方法),不能推广到所有库存控制规则,也不检验第二章的精确解。第四,夏普比率不是阿韦拉内达—斯托伊科夫的目标函数,夏普比率较高不等于期望效用较高。第五,模拟器中的延迟、排队竞争与手续费都是简化的,而在真实市场中它们往往决定做市的盈亏。第六,它不检验第三章的霍克斯模型、第四章的 VPIN 或第五章的不平衡指标,这些需要各自的检验。第七,试点环境中的大效应来自作者自己的模型,这正是需要独立模拟器与预注册的原因;如果独立实验得到「没有值得据此改变做法的差别」,那就是这项实验的结论。

伦理与利益冲突

这项实验不涉及人体受试者,不需要伦理委员会审批,也不涉及任何真实交易或资金;但方案、模拟器配置、脉冲生成脚本、策略代码与分析代码须在运行之前公开登记。无论结果是正是负,结果、代码与全部会话的汇总数据都将公开。为限制利益的影响:方案与代码在第三方运行前公开登记,作者不接触种子与脉冲时间表,无论结果如何都发表。

利益披露

作者以 5D Library 的著作(包括本书)作为其社群课程、升维牌卡(5D Ascension Cards,Dimensional Shift Card Decks)与 Yafu AI 知识库的方法论基础,因此与本书主题有商业利益关系。本书不推销任何课程、牌卡或服务;第八章的试验设计为由独立于作者企业的研究人员实施和分析,不从作者的社群、学员或客户中招募;书中所有代码与研究方案均公开,供任何人检验。作者开发并维护量化研究脚本,并提供相关的开源研究与独立咨询服务;撰写本书期间可能持有美股指数(如 SPY)或相关衍生品的常规观察仓位。本书所有模型仅供数理与历史统计的学术探讨,不构成任何投资建议或交易信号,也不推荐任何具体交易或资产。

本章小结

四步核查表从逆向选择、订单流、库存与执行四个方面审视一个交易日;示例显示,逆向选择只有按方向分开的已实现价差才看得清,库存偏置会在合计数字中把它掩盖。预注册的模拟撮合实验在独立第三方冻结的模拟器中,以配对的 8,600 个会话比较库存偏置与固定对称报价在毒性脉冲下的跨会话夏普比率,唯一主要结局为二者之差,最小关注效应 0.31,双盲运行,判定规则写成代码,并预先规定了「平均收益较低」的限定语;无论结果如何都发表。它只检验一种报价规则在一种模拟器中的表现,不能证明本书的其他模型,也不能直接推及真实市场。

参考文献

Byrd, David, Maria Hybinette, and Tucker Hybinette Balch. 2020. “ABIDES: Towards High-Fidelity Multi-Agent Market Simulation.” Proceedings of the 2020 ACM SIGSIM Conference on Principles of Advanced Discrete Simulation (SIGSIM-PADS ’20), 11–22.
Jobson, J. D., and Bob M. Korkie. 1981. “Performance Hypothesis Testing with the Sharpe and Treynor Measures.” Journal of Finance 36 (4): 889–908.
Ledoit, Olivier, and Michael Wolf. 2008. “Robust Performance Hypothesis Testing with the Sharpe Ratio.” Journal of Empirical Finance 15 (5): 850–59.
Lo, Andrew W. 2002. “The Statistics of Sharpe Ratios.” Financial Analysts Journal 58 (4): 36–52.
Memmel, Christoph. 2003. “Performance Hypothesis Testing with the Sharpe Ratio.” Finance Letters 1: 21–23.
Nosek, Brian A., Charles R. Ebersole, Alexander C. DeHaven, and David T. Mellor. 2018. “The Preregistration Revolution.” Proceedings of the National Academy of Sciences 115 (11): 2600–2606. https://doi.org/10.1073/pnas.1708274114.

Fan, Y. (2026). High-Frequency Limit Order Book Microstructure, Hawkes Self-Exciting Point Processes and Adverse-Selection Flow Toxicity: From the Avellaneda–Stoikov Market-Making Equations to VPIN, Read Beside Classical Chinese Thought on Market Equilibrium [高频限价订单簿微观结构、霍克斯自激点过程与逆向选择毒流] (Version 1.0.0). 5D Library. https://doi.org/10.5281/zenodo.23828065 · Licensed under Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0).