OFI Alpha Pipeline加密永续最小可实盘架构
一、加密永续 ≠ 股票 / 期货(先立边界)
在进入 Pipeline 之前,先给你三个必须内化的差异:
1️⃣ 没有“真实做市义务”
→ 流动性 极不稳定
2️⃣ 订单簿极易被操纵
→ spoof / cancel 比传统市场严重得多
3️⃣ 多交易所、弱监管
→ Lead-Lag 极其重要
所以在加密永续中:
OFI 的主要价值是“执行与确认”,而不是单独找方向
二、加密永续 Microstructure Alpha Pipeline(整体图)
┌──────────────────────────────────────────────┐
│ ① 数据层:Exchange Feeds (Event-driven) │
│ L2 LOB / Trades / Funding / Mark Price │
└──────────────────────────────────────────────┘
↓
┌──────────────────────────────────────────────┐
│ ② Regime 层:加密特有状态识别 │
│ Vol / Liquidity / Funding / Liquidation Risk │
└──────────────────────────────────────────────┘
↓
┌──────────────────────────────────────────────┐
│ ③ Alpha 层(多信号) │
│ Lead-Lag / OFI / Aggressive Volume / │
│ Micro-price / Short Momentum │
└──────────────────────────────────────────────┘
↓
┌──────────────────────────────────────────────┐
│ ④ 决策融合(State-conditioned Alpha) │
│ 权重动态 / 非线性压缩 / Kill rules │
└──────────────────────────────────────────────┘
↓
┌──────────────────────────────────────────────┐
│ ⑤ Execution 层(永续专用) │
│ Post-only / IOC / Reduce-only / TWAP slices │
└──────────────────────────────────────────────┘
↓
┌──────────────────────────────────────────────┐
│ ⑥ 风险与反馈(永续特有) │
│ Leverage / Liquidation buffer / Slippage │
└──────────────────────────────────────────────┘
三、① 数据层(Crypto-Perp 实战)
必须的数据(最低配置)
L2 Order Book(增量)
- 深度:L1–L10(够用)
- 必须是 diff / update
- snapshot + delta 校验(否则 OFI 会坏)
Trades
- 成交方向(taker buy / sell)
- 成交量
- 时间戳
价格
- mid-price
- mark price(⚠️ 永续特有)
- index price(跨所用)
📌 注意:
OFI 一定基于 order book 更新,不是 trade
四、② Regime 层(加密特有)
这是加密策略最重要的一层。
1️⃣ 波动率 Regime
vol = EWMA(std(log(mid_return)))
规则:
- vol > Q95 → 禁止开新仓
- vol > Q99 → 强制平仓
2️⃣ 流动性 Regime(非常重要)
depth = sum(bid_L1-L5) + sum(ask_L1-L5)
spread = ask1 - bid1
过滤:
if spread > Q90 or depth < Q20:
trading_allowed = False
3️⃣ Funding Regime(永续独有)
if abs(funding_rate) > threshold:
reduce directional exposure
📌 避免:
- 顺着 funding 拿仓
- funding 驱动的假趋势
4️⃣ 清算风险(隐形雷)
- open interest 变化
- 大幅 move + 成交量暴涨
if liquidation_cluster_detected:
disable alpha
五、③ Alpha 层(加密永续版本)
1️⃣ Lead-Lag(核心方向)
最常见组合
- BTC → ETH
- Binance → OKX
- Perp → Spot
LeadLag = sign(Δprice_lead)
📌 Lead-Lag 给方向
2️⃣ OFI(确认 + 执行)
加密专用 OFI(建议)
OFI =
Δbid_size @ best_bid
- Δask_size @ best_ask
然后:
OFI_scaled =
OFI
/ depth
/ σ_price
📌 必须做 depth + vol 调整(加密太极端)
3️⃣ Aggressive Volume(真假判断)
AV = taker_buy_vol - taker_sell_vol
- OFI 强 + AV 强 → 真突破
- OFI 强 + AV 弱 → spoof
4️⃣ Micro-price 偏移
micro_price =
(ask1 * bid_size + bid1 * ask_size) /
(bid_size + ask_size)
六、④ 决策融合(Crypto 风格)
alpha_raw =
w1 * LeadLag +
w2 * OFI_scaled +
w3 * AV +
w4 * micro_price_dev
状态条件化
if funding_extreme:
w1 ↓
if liquidity_thin:
w2 ↓
非线性压缩
alpha = tanh(alpha_raw)
📌 永远不要裸用线性 alpha
七、⑤ Execution 层(永续专用细节)
OFI → 执行方式
if OFI_z > 3:
IOC / Market
elif OFI_z > 1:
Post-only limit
else:
wait
订单标志(非常重要)
postOnly = TruereduceOnly = True(平仓)- 限制每次下单 size
📌 防止 maker 变 taker 被割手续费
八、⑥ 风险与反馈(永续生死线)
仓位控制
position ≤ equity × max_leverage × risk_factor
清算缓冲
liquidation_distance > min_buffer
执行反馈
if OFI strong but slippage ↑:
decrease aggressiveness
📌 系统要“学会不信盘口”
九、最小可跑的 Crypto-Perp Pipeline(伪代码)
if not regime_ok():
return
leadlag = leadlag_btc_to_eth()
ofi = ofi_scaled()
av = aggressive_volume()
alpha = tanh(
0.5 * leadlag +
0.3 * ofi +
0.2 * av
)
size = base_size * abs(alpha)
if alpha > 0:
side = BUY
else:
side = SELL
execute(
side=side,
size=size,
aggressiveness=ofi
)
十、一句话给你(加密永续真相)
在加密永续里,OFI 的价值不是“预测价格”
而是“告诉你盘口是不是在配合你下注”