malkhut: Flight9 learnings — markout=quality, queue×flow, depth-for-size
Fable's Flight9/BLUE generalizable features incorporated: 1. Slippage model gains trade_flow_intensity parameter: - Estimated from book imbalance (proxy for trade arrivals) - More flow → better fills (lower slippage) - Fable: 'fill = queue position × trade-flow intensity' 2. Markout = quality concept documented: - Score fills by post-fill markout, not just fill/no-fill - Maker fills are adversely selected 3. Depth-for-size documented: - Spread lies; key on depth-within-K-bps vs order notional 4. Measured fees: - BingX maker=2.00bp, taker=5.016bp (over 1,455 fills) - BingX commission = NEGATIVE (debit) 5. OB study updated with Flight9 learnings
This commit is contained in:
@@ -64,8 +64,18 @@ class SlippageCalibration:
|
||||
order_usd: float = 0.0,
|
||||
book_depth_usd: float = 1.0,
|
||||
is_mainnet: bool = False,
|
||||
trade_flow_intensity: float = 0.0,
|
||||
) -> float:
|
||||
"""Predict slippage. Switches model based on book depth."""
|
||||
"""Predict slippage. Switches model based on book depth.
|
||||
|
||||
Generalizable features (Fable, Flight9/BLUE):
|
||||
1. Fill = queue position × trade-flow intensity (not just book snapshot)
|
||||
2. Depth-for-size > spread (spread lies — unfillable behind $977)
|
||||
3. Markout = quality (post-fill adverse selection)
|
||||
"""
|
||||
# Flow intensity boost: more trade arrivals → higher fill probability
|
||||
flow_boost = 1.0 + trade_flow_intensity * 0.1
|
||||
|
||||
if book_depth_usd < self.thin_book_threshold_usd:
|
||||
# THIN BOOK: intercept-dominant (alts, meme coins)
|
||||
# The fill walks the entire book in 1-2 levels.
|
||||
@@ -77,6 +87,9 @@ class SlippageCalibration:
|
||||
depth_ratio = order_usd / max(book_depth_usd, 1.0)
|
||||
base = self.alpha * levels_consumed + self.beta * depth_ratio
|
||||
|
||||
# Adjust for flow intensity: more flow = better fills (lower slippage)
|
||||
base /= max(flow_boost, 0.5)
|
||||
|
||||
if is_mainnet:
|
||||
base *= self.testnet_to_mainnet
|
||||
return base
|
||||
@@ -123,10 +136,11 @@ class SlippageRegistry:
|
||||
order_usd: float = 0.0,
|
||||
book_depth_usd: float = 1.0,
|
||||
is_mainnet: bool = False,
|
||||
trade_flow_intensity: float = 0.0,
|
||||
) -> float:
|
||||
"""Predict slippage using the appropriate model."""
|
||||
model = self.get(symbol)
|
||||
return model.expected_slippage_bps(levels_consumed, order_usd, book_depth_usd, is_mainnet)
|
||||
return model.expected_slippage_bps(levels_consumed, order_usd, book_depth_usd, is_mainnet, trade_flow_intensity)
|
||||
|
||||
|
||||
# ==============================================================================
|
||||
@@ -219,6 +233,7 @@ def expected_slippage_bps(
|
||||
order_usd: float = 0.0,
|
||||
book_depth_usd: float = 1.0,
|
||||
is_mainnet: bool = False,
|
||||
trade_flow_intensity: float = 0.0,
|
||||
) -> float:
|
||||
"""Predict slippage using Flight7-calibrated model."""
|
||||
return REGISTRY.expected_slippage_bps(symbol, levels_consumed, order_usd, book_depth_usd, is_mainnet)
|
||||
return REGISTRY.expected_slippage_bps(symbol, levels_consumed, order_usd, book_depth_usd, is_mainnet, trade_flow_intensity)
|
||||
|
||||
Reference in New Issue
Block a user