Works with the AI Agents you already use

    Regime Detection Volatility

    by BanditXBT

    1

    Detect market regimes and forecast volatility without lookahead: HMM, Markov switching, GARCH, change points, vol targeting.

    $29

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned

    About this skill

    Regimes are latent; every label used in a backtest must be a filtered, real-time estimate from parameters fit only on past data, never a smoothed or full-sample one. Educational analysis, not investment advice; state assumptions and data sources.

    1. Pick the question. Continuous volatility forecast for sizing vs discrete state for strategy switching. Prefer 2-3 states; more mostly fit noise.
    2. Volatility estimators.
      • EWMA: s2_t = lam*s2_{t-1} + (1-lam)*r_{t-1}^2. RiskMetrics defaults are lam = 0.94 (daily) and 0.97 (monthly). Half-life = ln(0.5)/ln(lam), about 11 days at 0.94.
      • GARCH(1,1): s2_t = w + a*r_{t-1}^2 + b*s2_{t-1}; unconditional variance w/(1-a-b); daily a+b is often fitted near 0.97-0.99 (empirical tendency, varies). GJR-GARCH/EGARCH capture leverage effect; Student-t innovations suit fat tails. Python: arch.arch_model(r*100, vol="GARCH", p=1, o=1, q=1, dist="t") (o=1 gives GJR); vol="EGARCH" for EGARCH. Refit on rolling windows; use forecast() out of sample.
      • Realized vol from intraday returns (e.g., 5-minute; check microstructure noise); HAR-RV (Corsi 2009) is a simple strong baseline.
      • Evaluate forecasts out of sample with QLIKE or MSE (both robust to noisy proxies, Patton 2011) and Mincer-Zarnowitz regressions; compare models with Diebold-Mariano or arch.bootstrap.MCS (Model Confidence Set).
    3. Markov switching (Hamilton 1989). statsmodels.tsa.regime_switching.markov_regression.MarkovRegression(endog, k_regimes=2, switching_variance=True) (also MarkovAutoregression). Results expose smoothed vs filtered marginal probabilities (smoothed_marginal_probabilities, filtered_marginal_probabilities; verify names in your version). Only filtered ones are causal, and only if parameters were also estimated on past data: refit expanding/rolling. Expected duration 1/(1-p_ii).
    4. Gaussian HMM. hmmlearn.hmm.GaussianHMM(n_components=k, covariance_type="full", n_iter=500); multiple random inits (EM finds local optima), compare BIC, sort states by variance after each refit (label switching). In hmmlearn, predict is Viterbi and predict_proba returns posteriors using the whole sequence, so neither is causal on a full-sample call. For a filtered probability at t, fit on data up to t (or fit earlier, then call predict_proba on data truncated at t and take the last row); this is O(T^2) but correct.
    5. Change points. Offline: PELT (Killick, Fearnhead, Eckley 2012, JASA) via ruptures: rpt.Pelt(model="rbf", min_size=..., jump=...).fit(x).predict(pen=...). Online: Bayesian online changepoint detection (Adams and MacKay 2007, arXiv:0710.3742); CUSUM. The penalty drives results; calibrate on simulated null data to a target false-alarm rate. Offline detectors see the whole series and are not trading signals.
    6. Volatility targeting. w_t = min(L_max, sigma_target / sigma_hat_t) with sigma_hat known at t-1, executed at t. Moreira and Muir (J. Finance 2017) report volatility-managed portfolios earn large alphas for equity factors and the currency carry trade. Harvey et al. (J. Portfolio Mgmt 2018) find Sharpe gains for risk assets with a leverage effect (equities, credit) and negligible effects for bonds, currencies, commodities; vol targeting consistently reduced extreme negative returns. Add leverage caps, rebalance thresholds (e.g., trade only if weight change > 10-20%, heuristic), and cost and financing accounting.
    7. Regime-conditioned evaluation. Tag each bar with the filtered regime known at t-1. Report per-regime return, vol, Sharpe, drawdown, turnover and independent episode count (not bars). Test alpha differences with r_t = a + b*f_t + c*I + d*(f_t*I) + e, HAC errors.

    Educational analysis, not investment advice. Verify statsmodels attribute names against your installed version.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Money-back guarantee

    Doesn't do what its page promises? You get your money back.

    Trust & safety

    Security scan

    Security scan passed 13 days ago

    Software
    Python 3statsmodelsarch
    Optional
    hmmlearnruptures

    Permissions

    No special permissions declared or detected

    Listed13 days ago

    What's inside

    Frequently Asked Questions

    Detect market regimes and forecast volatility without lookahead: HMM, Markov switching, GARCH, change points, vol targeting.

    This skill uses the open SKILL.md standard. Use it through an MCP-compatible agent connected to Agensi, and check the compatibility information on this page for confirmed agents and required capabilities.

    Connect your AI agent to Agensi through MCP, then ask it to use regime-detection-volatility on your task. Your agent loads the latest approved version each time. Paid skills require a purchase or active subscription. Skill files are not available for download; your licence does not allow you to save, copy or export any part of a skill.

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse All Claude Skills.