A market regime is context, not a crystal ball.
Use probabilistic state estimates to ask better questions about exposure and strategy selection.
| Section | Sources cited | Equations | Code listings |
|---|---|---|---|
| 1. Separate causal filtered probabilities from retrospective smoothing | 1, 2, 3 | 1 | 0 |
| 2. Anchor state identities and penalize controller churn | 1, 2 | 0 | 1 |
01 /Separate causal filtered probabilities from retrospective smoothing
Markets do not maintain a single stationary covariance or liquidity structure. Volatility, cross-asset correlations, and order-book depth shift across calm and stressed episodes. A probabilistic regime model summarizes that evolving context into a state distribution rather than claiming to predict every price movement.
Hidden Markov models and Markov-switching regressions infer latent states from observed return and volatility series [1, 3]. QuantConnect’s research documentation demonstrates how volatility-state inference integrates into an event-driven algorithmic environment [1].
The decisive implementation boundary is causality: a tradable controller may condition only on the filtered state vector , never on the Kim-smoothed retrospective distribution , which embeds future crisis realizations into historical weights [2, 3].
Here P is the K×K row-stochastic transition matrix, η_t is the state emission likelihood vector at time t, and L_t scales gross portfolio exposure.
02 /Anchor state identities and penalize controller churn
A useful specification defines exactly what the estimated state is permitted to modify: gross exposure, risk budgets, or strategy blending weights [1, 2]. When models are refitted across rolling windows, state indices must be anchored by ordering emission variances to prevent label switching.
We benchmark any Markov-switching controller against a transparent realized-volatility threshold rule across rolling chronological splits [2], testing whether regime-conditioned de-risking reduces tail drawdowns after accounting for rebalancing turnover. The one-step fixture below checks filtering arithmetic, not portfolio performance.
- Condition live sizing exclusively on filtered probabilities π_{t|t}; reserve smoothed states π_{t|T} for diagnostics.
- Use fitted emission variance to anchor state labels across refits, while checking whether the states’ economic interpretation has changed.
- Apply a deadband or exponential smoothing to state probabilities so boundary oscillations do not churn the portfolio.
# Illustrative only; causal 2-state Hamilton filter step without future smoothing.
import numpy as np
P = np.array([[0.97, 0.03], [0.10, 0.90]])
sigmas = np.array([0.008, 0.028])
pi = np.array([0.85, 0.15])
def hamilton_step(pi_prev: np.ndarray, r_t: float) -> np.ndarray:
prior = P.T @ pi_prev
likelihood = np.exp(-0.5 * (r_t / sigmas) ** 2) / (np.sqrt(2.0 * np.pi) * sigmas)
post = prior * likelihood
return post / np.sum(post)
calm_post = hamilton_step(pi, 0.002)
shock_post = hamilton_step(pi, -0.045)
assert np.isclose(np.sum(calm_post), 1.0) and np.isclose(np.sum(shock_post), 1.0)
assert shock_post[1] > calm_post[1]
print(f"stress_prob_calm={calm_post[1]:.3f}, stress_prob_shock={shock_post[1]:.3f}")Research is complete only when the assumptions, experiment, and limitations can be reconstructed.
This perspective is research commentary. It does not constitute investment advice or evidence of live strategy performance. Experimental methods require project-specific testing. Equations and code illustrate research formulations, not measured live returns.