关于「实践与预注册检验」,《订单簿微观结构与毒流》给出的定量结论是什么?
结论:第八章给出逆向选择、订单流、库存与执行四步核查表,以及一项预注册的模拟撮合实验方案:在独立第三方冻结的模拟器中,比较库存偏置的阿韦拉内达—斯托伊科夫报价与固定对称报价在毒性脉冲下的跨会话夏普比率(唯一主要结局为二者之差,最小关注效应 0.31,8,600 个配对会话,双盲运行,判定规则写成代码)。书中以标注框区分已发表的证据、可运行的 Python 计算(16 段程序)、原典与作者的模型和假说;书中所有数据都是虚构或模拟的。
数据口径:做市商为什么要留出买卖价差?订单为什么成簇到来?能否从成交数据中度量「有毒」的订单流?本书是教学与研究用的数学模型,不是投资或交易建议。 第八章给出逆向选择、订单流、库存与执行四步核查表,以及一项预注册的模拟撮合实验方案:在独立第三方冻结的模拟器中,比较库存偏置的阿韦拉内达—斯托伊科夫报价与固定对称报价在毒性脉冲下的跨会话夏普比率(唯一主要结局为二者之差,最小关注效应 0.31,8,600 个配对会话,双盲运行,判定规则写成代码)。
对照数据表
下表数字由本章 Python 程序原样打印,可重新运行复现。 程序只用 Python 标准库与结论吻合的打印值: 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
查看完整验算程序
# 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))唯一数据源与引用
范雅福(Fan, Y.). (2026). 《高频限价订单簿微观结构、霍克斯自激点过程与逆向选择毒流》第 8 章「实践与预注册检验」(版本 1.0.0). 5D Library. https://doi.org/10.5281/zenodo.23828065
DOI: 10.5281/zenodo.23828065 · 阅读本章所在专著 · 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}
}