Markov Hedge Fund Method (Regime Detection Skill)
Detects Bull / Bear / Sideways regimes on any asset and turns them into a tradeable signal or risk gate you can layer onto an existing strategy.
Read-only data analysis; no API keys/accounts/sudo; data flow (yfinance or user CSV) explicitly disclosed; graceful HMM degrade; clear disclaimers; MIT license with framework attribution to Roan. Deducted: the actual script is not provided for review, so least-privilege behavior and input validation cannot be verified; uv resolves dependencies dynamically from PyPI with no lockfile or dependency audit; no rollback mechanism.
Documentation is self-consistent: field-by-field JSON contract, non-zero exit with {"error} on failure, HMM graceful-degrade path, no-lookahead walk-forward claim all align. Deducted: the script source is not in scope-provided evidence, so key paths (matrix estimation, NaN handling, CSV column auto-detection) cannot be statically confirmed; no tests or edge cases are visible.
Trigger semantics are precise: named scenarios (regime detection, confirmation layer, risk gate, sizing filter), clear inputs (ticker or CSV), stated defaults. Deducted: no Chinese-language support mentioned; yfinance may be unreachable from mainland-China networks, and core function depends on it; behavior on short histories only partially disclosed via walk_forward NaN note.
Well-layered docs (README → SKILL.md → JSON contract → composition patterns), complete MIT LICENSE, clear attribution, and a zero-trust manual install path. Deducted: repo license metadata is NOASSERTION; SKILL.md has no version or changelog; maintenance responsibility and update path are unclear (a personal YouTube link is not a maintenance commitment).
Claimed capability is complete with copy-ready composition snippets and a concrete marginal value story (signal/risk layer). Deducted: static review cannot verify outputs are directly usable; walk-forward backtest correctness and reported Sharpe are unchecked; financial-benefit claims per anchors require executed evidence, which is absent.
Auditable primary material exists: full JSON contract, documented defaults, repro params matching the on-camera demo (--threshold 0.02), and reference to the original article. Deducted: no test suite, no committed third-party execution evidence, no sample outputs to cross-check results; fact/inference separation rests on author claims.
- This is a static review; no code was executed. Script logic, backtest figures, and JSON output are independently unverified.
- Dependencies resolve dynamically from PyPI via uv with no lockfile — a supply-chain risk. Inspect the PEP 723 inline metadata and pin versions.
- yfinance may be unreachable from mainland-China networks; the ticker path may be unusable there — fall back to --csv with your own data.
- Output is a trading signal for educational purposes; validate via the walk-forward Sharpe and max drawdown before any live use.
- Repo license metadata is NOASSERTION and the publisher is unverified; SKILL.md lacks versioning and a changelog — diff carefully on updates.
What does this skill do, and when should you use it?
This skill accompanies video 1 of the Quant Series, built on a framework by Roan (@RohOnChain) and refactored into a plugin by Lewis Jackson. It labels each day of any asset's history Bull / Bear / Sideways via a rolling-return rule, fits a maximum-likelihood 3×3 Markov transition matrix, and forecasts n-steps ahead via Chapman-Kolmogorov, alongside the long-run stationary distribution and a no-lookahead walk-forward backtest (Sharpe, max drawdown). Input is either any yfinance ticker (stocks, ETFs, crypto, FX, futures) or your own CSV price file. It is explicitly designed to compose — as a confirmation layer, standalone signal, or tail-risk filter — without rewriting an existing trading agent.
Runs scripts/markov_regime.py: accepts --ticker (prices fetched via yfinance) or --csv (needs only date and close columns, with common column names auto-detected); labels each bar using defaults of a 20-day window and ±5% threshold over 10 years of history; estimates a 3×3 Markov transition matrix; computes next-state probabilities and the stationary distribution; emits signal = bull_prob − bear_prob in [-1, 1]; runs a re-estimated-every-step, no-lookahead walk-forward backtest reporting Sharpe and max drawdown; optionally fits an HMM via hmmlearn that degrades gracefully if it cannot compile. With -- it prints exactly one structured object containing current_regime, signal, transition_matrix, stationary_distribution, walk_forward, and more.
- A trader with an existing momentum strategy who wants regime confirmation before entries: take longs only when the strategy and regime signal agree
- Risk management: scale position sizes down (or gate to zero) based on the asset's long-run Bear share in the stationary distribution
- An individual investor who wants a quick read on where an asset like BTC-USD or AAPL stands, how sticky that state is, and directional probabilities
- A quant with their own CSV price data who wants the same regime detection on any asset or timeframe their pipeline produces
- A TradingView user who wants the companion Pine Script v5 indicator showing the regime ribbon, live transition matrix, and stationary-distribution table on a chart
What are this skill's strengths and limitations?
- Zero-trust friendly: the original build prompt is kept in-repo so you can read every line before installing
- No-lookahead walk-forward backtest that re-estimates the matrix at every step
- Asset-agnostic: any yfinance ticker or your own CSV, with minimal input requirements (one date and one close column)
- Graceful HMM degradation and a clean, well-documented JSON contract for programmatic integration
- Includes a TradingView Pine Script indicator for visual verification of the framework
- Backtests are historical, not forward-looking — the repo itself states this repeatedly
- GitHub license metadata is NOASSERTION; only the README claims MIT via an umbrella LICENSE in a parent directory, which you should verify
- No evidence of a test suite or third-party audit; the repo has no topics and no formal releases
- Walk-forward Sharpe/max drawdown can be NaN when history is too short; HMM states are labelled by ascending mean return, so a 'Bear' state can still be net-positive, requiring careful interpretation
- The Pine indicator (v5) mirrors the Python defaults but is a separate implementation with no stated cross-verification
How do you install this skill?
Two commands in Claude Code: /plugin marketplace add jackson-video-resources/markov-hedge-fund-method then /plugin install markov-hedge-fund-method@markov-hedge-fund-method. No API keys, no accounts, no sudo; dependencies resolve on first run via uv (PEP 723 inline metadata, roughly 10–20 seconds). If you prefer not to install from a marketplace, markov-hedge-fund-method.md in the repo is the original one-shot onboarding prompt — paste it into Claude Code (agent mode) and it builds the identical skill from scratch locally, as a zero-trust fallback.
How do you use this skill?
Invoke with /markov-hedge-fund-method:regime or plain English prompts like "detect the regime on BTC-USD", "add a regime confirmation filter to my SPY momentum strategy", or "what's the long-run regime mix of AAPL". Programmatic use: uv run ${CLAUDE_PLUGIN_ROOT}/scripts/markov_regime.py --ticker BTC-USD --, or swap in --csv ./my_prices.csv. Drop -- for the pretty terminal output (matrix, persistence diagonal, walk-forward metrics, HMM line). All defaults (--window 20, --threshold 0.05, --years 10, --min-train 252) are overridable.
How does this skill compare with similar options?
The repo names no competitors. Compared with quant backtesting frameworks that embed regime features internally, this skill is deliberately a lightweight, composable layer — it does not require replacing your existing strategy or backtesting stack.