Latent Micro-Regime Early Detection in Limit Order Books
Identify structural market instability before it surfaces
A reproducible research framework for detecting latent build-up phases in financial markets. Fires with positive lead-time and 100% precision, exploiting the measurable delay between structural deterioration and observable stress.
β οΈ Research pipeline. Not a trading strategy. See Scope & Limitations below.
"Market stress does not arrive without warning. It accumulates."
Classical indicatorsβvolatility, order imbalance, spread wideningβare reactive. By the time they fire, the dislocation has already begun. This research asks a harder question: Can we detect the structural deterioration that precedes observable stressβbefore it becomes visible in price or spread?
Markets cycle through three distinct states. The critical regime is invisible to standard microstructure monitors.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β β β STATE 0 βββββββββββββΊ STATE 1 βββββββββββββΊ STATE 2 β β β β Stable Latent Build-up Stress β β βββββββ βββββββββββββββ ββββββ β β β’ Balanced liquidity β’ Depth eroding β’ Price shock β β β’ High resilience β’ Spread drifting β’ Visible β β β’ Equilibrium β’ β Hidden instability β’ Reactive β β β β Observable INVISIBLE Observable β β (past data) (our signal fires) (too late) β β β β βββββ detection window βββββΊ β β β β β β we detect stress begins β β β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
The key insight: The transition from State 1 β State 2 is not instantaneous. There is a measurable delay β and within that delay lives our detection window. We exploit it.
Why this matters: Depth erosion precedes spread widening, which precedes price impact. If we detect the book thinning silently, we have time to respond before the visible stress cascade begins.
Three independent signal channels. One fused trigger. Rising-edge detection instead of thresholds.
Uncertainty in regime classification
Why early: Rises as the latent state becomes ambiguous, before the transition to stress solidifies.
Recursive tracking of LOB depth erosion
Why early: Captures slow structural decay invisible to snapshot metrics. Liquid book β thin book is the first visible sign.
Imbalance between informed and uninformed flow
Why early: Signals adverse selection building in the book before visible spread impact.
MAX-Fusion Trigger
βββ Rising-edge detection
β ββ Onset of change, not absolute level
β ββ Bypasses noise floor that kills threshold methods
β
βββ Cross-channel aggregation
β ββ Fire when ANY channel breaches threshold
β
βββ Early-detection constraint
ββ Signal must precede stress (Ο < Ο)
Key design choice: We don't ask "is the spread wide?" We ask "is it getting wider right now?" This rising-edge approach bypasses the noise floor that kills absolute-threshold methods on real microstructure data.
Evaluated under full causal guarantees. No lookahead bias. No global statistics leaked to the predictor.
| Method | Lead-Time (steps) | Precision | Coverage |
|---|---|---|---|
| β Adaptive Trigger | +18.6 | 100% | 52.6% |
| HMM | +14.9 | 100% | 43.2% |
| Multi-Trigger | +13.1 | 100% | 28.1% |
| Order Imbalance | β24.8 | 54.9% | 78.7% |
| Volatility | β32.0 | 45.5% | 43.3% |
Reading the table: Positive lead-time means the signal fires before stress begins. Baseline methods are strictly negativeβthey lag. 100% precision means zero false starts during the latent phaseβevery trigger is temporally valid.
Market regimes structurally deteriorate before visible deterioration. Consistent empirical signature across tested sessions.
Depth decay in the LOB precedes spread widening and price impact. Book thinning is the earliest signal.
Posterior entropy is a structural stress barometer. Model uncertainty itself is informative.
Onset of deterioration carries more information than magnitude. No false starts from noise.
This pipeline was engineered to be trusted. Every result is verifiable and repeatable.
β Causal
No Lookahead
β Rolling Norm
No Data Leakage
β HMM Re-fit
Periodic
β Deterministic
Fixed Seeds
β Validated
Colab + M4
Causality verification: Rolling normalization onlyβno global statistics computed on future data. HMM re-fit every evaluation window. All results are exact under deterministic seeds across NVIDIA T4 (Google Colab) and Apple Silicon (M4 Pro/Max).
git clone https://github.com/prakulhiremath/LOB-Latent-Regimes.git
cd LOB-Latent-Regimes
pip install -r requirements.txtpython experiments/v7_final.pyExpected output:
[INFO] Loading normalized LOB snapshots... [INFO] Running causal evaluation pipeline... [INFO] Fitting HMM with rolling windows... [INFO] Computing signal channels (entropy, depth, toxicity)... [INFO] Fusing triggers with MAX aggregation... [INFO] Computing lead-time and precision metrics... ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β Adaptive Trigger +18.6 steps 100% precision 52.6% β β HMM +14.9 steps 100% precision 43.2% β β Multi-Trigger +13.1 steps 100% precision 28.1% β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
jupyter notebook notebooks/analysis.ipynbContains: Signal decomposition, lead-time distributions, regime transition visualizations, baseline comparisons.
LOB-Latent-Regimes/ β βββ experiments/ β βββ v1_baseline.py # Initial HMM formulation β βββ v2_entropy.py # Posterior entropy tracking β βββ v3_depth_drift.py # Temporal depth signal β βββ v4_triggers.py # Trigger logic development β βββ v5_fusion.py # MAX-fusion framework β βββ v6_rising_edge.py # Rising-edge detection β βββ v7_final.py # β Production pipeline β βββ notebooks/ β βββ analysis.ipynb # Experiment analysis + figures β βββ results/ β βββ figures/ # High-resolution performance plots β βββ summary.txt # Quantified results β βββ paper/ # Technical manuscript βββ assets/ # Visualizations, GIFs, detection timeline βββ requirements.txt # Dependencies βββ README.md
The pipeline evolved through 7 versions, each adding precision:
| Version | Focus | Key Innovation |
|---|---|---|
v1 |
Baseline HMM | Three-state Markov model for regime classification |
v2 |
Entropy Signal | Posterior entropy as stress barometer |
v3 |
Depth Drift | Temporal tracking of LOB depth erosion |
v4 |
Trigger Design | Individual signal thresholds |
v5 |
Multi-Signal Fusion | MAX aggregation across channels |
v6 |
Rising-Edge | Onset detection instead of absolute levels |
β
v7 |
Final Pipeline | Production configuration, full causal guarantees |
Be precise about what this is and is not.
Important: This is research code. Backtesting results do not guarantee forward performance. Live trading requires rigorous validation, risk management, and regulatory compliance beyond the scope of this work.
Model latent build-up β stress transition as a three-state latent process with explicit temporal separation.
Subtle depth and spread drift as leading precursor to liquidity voids. Recursive tracking without lookahead.
MAX-fusion + rising-edge trigger for sub-millisecond microstructure data. Positive lead-time guarantee.
Strictly positive lead-time over reactive benchmarks across all evaluated regimes. 100% precision.
@article{hiremath2026lob,
title = {Early Detection of Latent Micro-Regimes in Limit Order Books},
author = {Hiremath, Prakul Sunil and Hiremath, Vruksha Arun},
year = {2026},
doi = {10.5281/zenodo.19697687}
}
LOB Latent Regimes β Early Detection of Structural Market Instability
MIT License Β· Reproducible Research Pipeline Β· Open Source
"If the signal fires before the storm β it worked."