What Is Markov Hedge Fund Method?
Markov Hedge Fund Method is one of the best Trading Regime Analysis tools for quant traders and systematic developers. Built by Roan (@RohOnChain), this open-source Claude Code skill turns any asset into a three-state Bull/Bear/Sideways model with a 3×3 transition matrix, walk-forward backtest, and optional HMM support.
It is designed for traders who want regime awareness without wiring a full research stack from scratch. The repo packages the logic as a Claude Code plugin, a zero-trust manual build path, and a TradingView Pine Script overlay so the same framework can live in the terminal, notebook, or chart.
Quick Overview
| Attribute | Details |
|---|---|
| Type | Trading Regime Analysis Tools |
| Best For | quant traders and systematic developers |
| Language/Stack | Claude Code skill, Python, uv, yfinance, pandas, numpy, hmmlearn, Pine Script v5 |
| License | MIT |
| GitHub Stars | N/A |
| Pricing | Open-Source |
| Last Release | N/A |
Who Should Use Markov Hedge Fund Method?
- Quant traders building signal filters who want a regime layer before they size up a position or trigger an entry.
- Indie developers shipping crypto or equity research tools who need a small, auditable model instead of a black-box model zoo.
- Systematic strategy authors who already use momentum, mean reversion, or breakout rules and want a regime confirmation gate.
- TradingView users who want the same regime logic rendered directly on a chart with a ribbon, matrix, and stationarity table.
Not ideal for:
- Discretionary traders who want chart overlays but do not care about transition probabilities, stationary distributions, or backtest stats.
- Teams needing execution plumbing such as broker routing, order management, or portfolio accounting; Markov Hedge Fund Method stops at signal and analysis.
- Researchers demanding fully Bayesian inference on latent states; the default path is a practical threshold model, not a probabilistic thesis engine.
Key Features of Markov Hedge Fund Method
- Three-state regime labeling — The default logic maps each day to Bull, Bear, or Sideways using a rolling return window, with 20-day lookback and ±5% thresholds as the shipped baseline. That gives you a small, interpretable state space instead of a noisy continuous score.
- 3×3 transition matrix — The skill estimates regime persistence with maximum-likelihood counts from historical transitions. That means you can inspect whether Bull tends to stick, flip, or decay into Sideways before you trust a signal.
- Multi-step regime forecasting — Markov Hedge Fund Method raises the transition matrix to higher powers using Chapman-Kolmogorov style forecasting. In practice, that lets you ask what the regime mix looks like one, five, or twenty steps ahead.
- Stationary distribution output — The tool computes the long-run equilibrium regime mix, which is useful when you want a baseline for whether current prices look unusually tail-heavy. This is the number you compare against your current regime snapshot before you size risk.
- Signed conviction signal — The framework emits
bull_prob − bear_probas a directional score, so the output is not just classification but also a confidence-weighted bias. That makes it easy to wire into a rule likeonly trade when conviction > 0.25. - Walk-forward backtesting — Markov Hedge Fund Method runs a no-lookahead evaluation and reports metrics such as Sharpe ratio and max drawdown. That matters because regime classifiers can look good in-sample and fail instantly when the data is re-shuffled out of time.
- Flexible data ingestion — You can feed it a ticker through
yfinanceor pass a local CSV with date and close columns. That means the same skill works for BTC-USD, SPY, AAPL, or a proprietary dataset already sitting in your warehouse. - Optional HMM path — The repo can fit a Hidden Markov Model via
hmmlearnwhen the dependency compiles cleanly, and it degrades gracefully if the environment cannot build it. That is a sane trade-off for a skill that needs to run in mixed developer environments.
Markov Hedge Fund Method vs Alternatives
| Tool | Best For | Key Differentiator | Pricing |
|---|---|---|---|
| Markov Hedge Fund Method | Claude Code-native regime analysis and backtesting | Packaged workflow with plugin install, CSV/ticker input, and Pine Script bonus | Open-Source |
| Plain Python notebook | Researchers who want total control over every line of logic | Maximum flexibility, but you build the state machine, charts, and reporting yourself | Free |
| TradingView Pine Script | Chart-first traders who want visual regime overlays | Native chart UI and fast iteration on technical signals | Freemium |
hmmlearn notebook | Users who want low-level hidden-state modeling | Direct access to probabilistic modeling, but more glue code and less productization | Open-Source |
Pick the plain Python notebook if you want to prototype a new state definition, add custom features, or swap in your own matrix estimation logic. Pick TradingView if the chart is the product and you want a live overlay instead of a Claude workflow.
Pick hmmlearn if you care about latent-state modeling more than end-user ergonomics. If you want to stay inside Claude Code, Claude Code Canvas is useful for iterating on prompt-driven workflows, and Claude Context Mode helps when you want longer-lived session memory around the same research task.
How Markov Hedge Fund Method Works
Markov Hedge Fund Method starts with a discrete state model, not a neural net. It takes price history, computes rolling returns, and labels each day as Bull, Bear, or Sideways using threshold rules, then counts state transitions to estimate a first-order Markov chain.
The technical decision here is clarity over opacity. A 3×3 transition matrix tells you how sticky each regime is, and the stationary distribution tells you where the system tends to settle if market behavior repeats long enough under the same assumptions.
The forecasting path is equally simple to reason about. If you want the probability of being in each regime after n steps, the skill raises the transition matrix to the nth power, then compares that forecast with the current regime mix and emits a signed directional score.
/plugin marketplace add jackson-video-resources/markov-hedge-fund-method
/plugin install markov-hedge-fund-method@markov-hedge-fund-method
/markov-hedge-fund-method:regime --ticker BTC-USD --lookback 20 --bull 0.05 --bear -0.05
That workflow installs the Claude Code plugin and then runs the regime analysis on BTC-USD with the default window and thresholds. If you prefer local data, swap --ticker BTC-USD for --csv my_prices.csv, where the file contains a date column and a close column.
Under the hood, the first run resolves dependencies with uv using inline metadata, so you do not need to pip-install the environment by hand. If hmmlearn compiles cleanly, Markov Hedge Fund Method can layer on a Hidden Markov Model; if it does not, the core Markov chain path still works.
Pros and Cons of Markov Hedge Fund Method
Pros:
- Fast to install in Claude Code — The two-command marketplace path gets you from repo to runnable skill without building your own package layout.
- Interpretable state machine — Bull/Bear/Sideways is easier to audit than an opaque score from a larger model.
- Works with both live tickers and local CSVs — That keeps it usable across research, backtests, and offline data pipelines.
- Backtest output is built in — Walk-forward evaluation with Sharpe and max drawdown reduces the chance that you trust a pretty chart with no evidence.
- Optional probabilistic upgrade path — The
hmmlearnlayer gives advanced users a second model family without forcing everyone onto it. - Chart-ready fallback — The Pine Script version makes it easy to inspect the same logic visually inside TradingView.
Cons:
- Thresholds are heuristic — The default ±5% regime boundary is practical, but it is still a rule, not a learned market truth.
- First-order Markov assumptions are restrictive — A 3×3 chain ignores higher-order dependencies and richer feature sets.
- No execution layer — You get analysis and signals, not broker integration or portfolio management.
- HMM support is optional — If
hmmlearnfails to compile in your environment, the advanced path is unavailable. - Data quality matters a lot — Bad CSVs, missing dates, or malformed closes will contaminate the transition counts quickly.
Getting Started with Markov Hedge Fund Method
/plugin marketplace add jackson-video-resources/markov-hedge-fund-method
/plugin install markov-hedge-fund-method@markov-hedge-fund-method
/markov-hedge-fund-method:regime --ticker SPY
After the install command runs, Claude Code resolves the skill dependencies on first execution and then generates the regime analysis for the asset you pass in. If you already have historical prices, use the CSV path instead and supply a file with date and close columns so the skill can build the state history cleanly.
If you want the chart version, open pine-script/markov-hedge-fund-method.pine in TradingView, paste it into Pine Editor, and add it to the chart. The overlay shows the regime ribbon, transition matrix, stationary distribution, and current-regime banner, which is enough for a quick sanity check before you promote the signal into a strategy.
Verdict
Markov Hedge Fund Method is the strongest option for Claude Code-based regime filtering when you want a reproducible Bull/Bear/Sideways layer without wiring a full research stack. Its biggest strength is the packaged workflow across plugin, CSV input, and Pine Script; the caveat is that threshold-driven regimes are still a simplification. Use it if you want fast, auditable signal generation.



