Depth Imbalance
Quick Reference
| Property | Value |
|---|---|
| Dimension | execution |
| Category | order_flow |
| Version | v0.9.0 (Beta) |
| Output Column | depth_imbalance |
Depth imbalance calculation: (sum(bid_depths) - sum(ask_depths)) / (sum(bid_depths) + sum(ask_depths) + epsilon)
Formula
CDM Inputs
| Column | CDM Table | Description |
|---|---|---|
cdm_lob_snapshot.bids | cdm_* | CDM source table |
cdm_lob_snapshot.asks | cdm_* | CDM source table |
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
epsilon | float [0.0, 1.0] | 1e-08 | Small value to prevent division by zero |
Output
Column: depth_imbalance
Depth imbalance ratio between -1 and 1
Market Intuition & Trading Rationale
Depth imbalance measures the asymmetry of resting liquidity: (total_bid - total_ask) / (total_bid + total_ask + ε). Values range from -1 (all depth on ask side — selling pressure) to +1 (all depth on bid side — buying support). Zero means the book is perfectly balanced.
This feature reveals where liquidity providers have committed capital. A positive imbalance means more resting bids than asks — market makers are willing to buy more than sell at current prices, suggesting they expect prices to rise. A negative imbalance means more resting asks — market makers expect prices to fall. Liquidity providers adjust their positioning before aggressive traders arrive, making depth imbalance a predictive signal.
The multi-level computation (extracting bid/ask sizes across all price levels, summing them) captures the full visible depth, not just the touch. A book can appear balanced at the touch but be heavily imbalanced at deeper levels — this feature captures the full picture. The epsilon term prevents division by zero in books where one side has been completely pulled.
Usage Cases
- Pre-trade direction prediction: A positive depth imbalance means more capital committed to buying than selling. Trade in the direction of the imbalance — liquidity providers are positioning for a move in that direction.
- Spoofing detection: Pair with
orderbook_update_rate. A rapid change in depth_imbalance combined with high update rates may indicate spoofing (placing and canceling large orders to create false imbalance). Cross-reference with trade_intensity — genuine imbalance should be confirmed by trading activity. - Execution timing: Execute buy orders when depth_imbalance is positive (more resting bids to absorb your sell). Execute sell orders when depth_imbalance is negative. Your order faces less slippage when there's ample resting liquidity on the opposite side.
- Liquidity stress context: In the
depth_imbalancefeature set, this feature is paired withcumulative_depth_slopeandcoefficient_of_variation. Stable imbalance in a deep, consistent book is a high-quality signal. Fluctuating imbalance in a shallow, volatile book is noise.
YAML Definition
name: depth_imbalance
description: 'Depth imbalance calculation: (sum(bid_depths) - sum(ask_depths)) / (sum(bid_depths)
+ sum(ask_depths) + epsilon)'
category: order_flow
version: v0.9.0 (Beta)
dimension: execution
status: Pre-release
required_inputs:
- cdm_lob_snapshot.bids
- cdm_lob_snapshot.asks
output_column: depth_imbalance
output_description: Depth imbalance ratio between -1 and 1
tags:
- depth
- imbalance
- orderbook
- lob
- microstructure
parameters:
epsilon:
type: float
description: Small value to prevent division by zero
required: false
default: 1.0e-08
constraints:
min: 0.0
max: 1.0
steps:
- primitive: TRANSFORM
op: array_extract
params:
array: cdm_lob_snapshot.bids
field: size
output_col: bid_sizes
- primitive: TRANSFORM
op: array_extract
params:
array: cdm_lob_snapshot.asks
field: size
output_col: ask_sizes
- primitive: TRANSFORM
op: array_sum
params:
array: bid_sizes
output_col: total_bid_depth
- primitive: TRANSFORM
op: array_sum
params:
array: ask_sizes
output_col: total_ask_depth
- primitive: TRANSFORM
op: sub
params:
output_col: imbalance_numerator
a: cdm_lob_snapshot.total_bid_depth
b: cdm_lob_snapshot.total_ask_depth
- primitive: TRANSFORM
op: add
params:
output_col: total_depth
a: cdm_lob_snapshot.total_bid_depth
b: cdm_lob_snapshot.total_ask_depth
- primitive: TRANSFORM
op: add
params:
output_col: imbalance_denominator
a: total_depth
b: $epsilon
- primitive: TRANSFORM
op: div
params:
output_col: depth_imbalance
a: imbalance_numerator
b: imbalance_denominator