Liquidity & Positioning Features¶
Overview¶
The Liquidity feature block constructs market microstructure and positioning indicators from bid–ask data, trading volume, open interest, and ATM implied volatility.
These features operate exclusively on canonical underlying daily data and are designed to capture:
- Transaction cost proxies
- Liquidity stress and instability
- Positioning imbalance
- Volume and participation dynamics
Required Input Columns¶
The following columns must be present in the canonical underlying daily table:
| Column | Description |
|---|---|
bid |
Daily best bid price |
ask |
Daily best ask price |
mid |
Mid price (average of bid and ask) |
volume |
Underlying trading volume |
call_open_int_tot |
Total call open interest |
put_open_int_tot |
Total put open interest |
iv_atm_hist |
Historical ATM implied volatility |
If any required column is missing, the block raises an error.
Produced Feature Columns¶
Bid–Ask Spread Metrics¶
| Feature | Description |
|---|---|
ba_spread |
Absolute bid–ask spread |
ba_spread_pct |
Spread normalized by mid price |
ba_spread_vol_adj |
Spread scaled by ATM implied volatility |
The volatility-adjusted spread acts as a proxy for risk-adjusted transaction cost.
Open Interest & Positioning¶
| Feature | Description |
|---|---|
open_int_total |
Total open interest (calls + puts) |
open_int_imbalance |
Normalized call–put OI imbalance |
Open interest imbalance is defined as:
(Call OI - Put OI) / Total OI
and is null when total OI is zero.
Open Interest Dynamics¶
| Feature | Description |
|---|---|
call_oi_change_1d |
1-day change in call open interest |
put_oi_change_1d |
1-day change in put open interest |
These features capture daily positioning flow.
Volume & Participation¶
| Feature | Description |
|---|---|
volume_change_1d |
1-day percentage change in volume |
volume_to_oi |
Volume normalized by total open interest |
volume_shock_20d |
Volume relative to 20-day average |
The volume-to-OI ratio serves as a proxy for position turnover intensity.
Liquidity Stability¶
| Feature | Description |
|---|---|
spread_vol_20d |
Rolling volatility of bid–ask spread |
Higher values indicate unstable or stressed liquidity conditions.
Masking Rules¶
All liquidity features are masked (null) on rows where any of the following are missing:
bidaskmidvolume
This ensures partial data does not produce misleading liquidity signals.
How to Call This Feature Block¶
Recommended (Public API)¶
from ocf.features.api import liquidity_features
features = liquidity_features(
underlying_daily,
)
This validates schema correctness and enforces a stable output contract.
Direct Builder Access (Advanced)¶
from ocf.features.liquidity import build_liquidity_features
features = build_liquidity_features(
underlying_daily,
)
This assumes canonical inputs and skips schema validation.
As Part of the Composite Feature Set¶
from ocf.features.api import underlying_features
features = underlying_features(
underlying_daily,
include=["liquidity"],
)
Or combined with other feature blocks:
features = underlying_features(
underlying_daily,
include=["ohlcv", "iv", "liquidity"],
)
Note¶
- All features are daily and fully causal
- No intraday assumptions are made