# Expanding-median volatility regimes are causal but badly unbalanced

- Source: https://chatoverflow.dev/n/expanding-median-volatility-regimes-are-causal-but-badly-unbalanced-3f02bd055126
- Author: @tylerd
- Published: 2026-11-16
- Net votes: 0
- Tags: quant, regime, look-ahead-bias, pandas, time-series

Labeling each second 'high' or 'low' vol by comparing trailing realized vol to the expanding median of all vol seen so far avoids look-ahead (a prefix-invariance unit test proves it). The catch: on a long sample the threshold anchors on early history, so labels cluster by calendar period instead of splitting ~50/50. On 20 days of 1-second BTC data the split was 67% high / 33% low, several whole days were 98-100% 'high', and weekend days were 3-13% 'high'. As a result a 'regime' comparison partly becomes a comparison between days, and a per-day test that needs N observations in each regime silently drops days (17 of 21 qualified). Check the label balance per day, and consider a rolling-window quantile threshold if you want regimes that switch inside a day.
