Spread Percentile Deviation
Quick Reference
| Property | Value |
|---|---|
| Dimension | execution |
| Category | statistics |
| Version | v1.0 |
| Output Column | spread_pct_deviation |
Deviation of current spread from its rolling distribution 鈥?detects spread spikes
Formula
(best_ask_price - best_bid_price) - rolling_median((best_ask_price - best_bid_price), window)
CDM Inputs
| Column | CDM Table | Description |
|---|---|---|
best_bid_price | cdm_lob_snapshot | Order book snapshot data 鈥?depth levels, bid/ask prices and sizes |
best_ask_price | cdm_lob_snapshot | Order book snapshot data 鈥?depth levels, bid/ask prices and sizes |
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
window | integer | 60000 | Window for spread distribution estimation |
Output
Column: spread_pct_deviation
Current spread deviation from its rolling median in basis points
Market Intuition & Trading Rationale
Spread percentile deviation measures how unusual the current spread is: spread - rolling_median(spread, window). Unlike absolute spread, which varies hugely across instruments, this is self-calibrating 鈥?a 10 bps spread is normal for a small-cap but alarming for a large-cap, and this feature captures that distinction. A value near zero means business as usual; a large positive means the spread has spiked relative to its own history.
Spread spikes are the market's earliest stress signal. Before depth evaporates, before volatility rises, before prices move 鈥?spreads widen. Liquidity providers, facing elevated uncertainty, demand higher compensation to provide quotes. The rolling median (rather than mean) makes this robust to occasional extreme spikes that would contaminate a mean estimate.
The feature also detects abnormally tight spreads (negative deviation). This can indicate a temporary execution window 鈥?liquidity providers are competing aggressively 鈥?or a calm period where adverse selection risk is perceived as low.
Usage Cases
- Real-time stress gating: Trigger when deviation exceeds 3脳 rolling IQR. Defer new entries, reduce position sizes, switch to limit orders. This fires earlier than volatility-based stress indicators.
- Execution window detection: Negative deviation signals unusually tight spreads 鈥?an opportunity to execute cheaply. Accelerate scheduled orders during these windows.
- Adverse selection warning: Spread spikes without news often mean a large informed trader is active. Market makers detect the asymmetry and protect themselves. Avoid trading in the same direction until the spread normalizes.
- Mean reversion entry: Extreme spread spikes mean-revert as liquidity providers return. Monitor for the deviation peak and enter as it retraces toward zero.
YAML Definition
name: spread_percentile_deviation
description: Deviation of current spread from its rolling distribution 鈥?detects spread
spikes
category: statistics
dimension: execution
version: v0.9.0 (Beta)
required_inputs:
- best_bid_price
- best_ask_price
output_column: spread_pct_deviation
output_description: Current spread deviation from its rolling median in basis points
tags:
- execution
- spread
- stress
parameters:
window:
type: integer
description: Window for spread distribution estimation
required: false
default: 60000
formula: (best_ask_price - best_bid_price) - rolling_median((best_ask_price - best_bid_price),
window)