How jackson-video-resources/markov-hedge-fund-method works
Purpose and Distribution
This repository packages the “Markov Hedge Fund Method” as a Claude Code plugin/skill for regime detection on market price series. Its primary user-facing entry point is the regime skill, installed through the plugin metadata in .claude-plugin/plugin.json and invoked as /markov-hedge-fund-method:regime.
Core Regime Analysis Engine
The executable analysis implementation is scripts/markov_regime.py. It accepts either a market ticker, fetched through yfinance, or a user-provided CSV containing date and close data. Inline PEP 723 dependency metadata allows uv to provision runtime dependencies on first use.
The engine labels observations Bull, Bear, or Sideways from rolling returns using configurable lookback and threshold defaults.
Markov Modeling and Forecasting
scripts/markov_regime.py derives a 3×3 maximum-likelihood transition matrix from historical regime labels. It uses matrix powers for n-step regime forecasts and computes a stationary distribution as the long-run regime baseline.
Its main output translates predicted probabilities into a signed directional signal: bull probability minus bear probability, with associated conviction and regime-stickiness context.
Validation and Optional Statistical Path
The same Python pipeline performs a walk-forward backtest designed to avoid lookahead bias, reporting strategy-oriented metrics including Sharpe ratio and maximum drawdown. It can optionally fit a Hidden Markov Model using hmmlearn; this path degrades gracefully if that dependency cannot be installed or compiled.
Skill Contract and Composition Boundary
skills/regime/SKILL.md defines the Claude-facing invocation behavior, JSON output contract, inputs, and composition patterns. This is the integration boundary for agents or existing trading workflows: consumers can use the regime result as a standalone signal, trade-confirmation filter, or tail-risk gate without adopting a specific execution system.
The skill orchestrates user intent and invokes the Python analysis rather than embedding market-model logic itself.
Plugin Metadata and Installation
.claude-plugin/marketplace.json and .claude-plugin/plugin.json expose the repository to Claude Code’s plugin marketplace and map the installed plugin to its skill content. The plugin has no service backend, credentials, or account requirement; market-data access occurs directly from the local runtime via yfinance when ticker input is selected.
Alternate Delivery and Visualization Artifacts
markov-hedge-fund-method.md is a transparent/manual bootstrap artifact that instructs Claude Code to create and validate an equivalent local skill installation. It is an alternate onboarding route, not part of normal runtime execution.
pine-script/markov-hedge-fund-method.pine is an independent TradingView Pine Script v5 indicator. It implements chart-side visualization of regime state, transition probabilities, and stationary distribution, but does not share runtime integration with the Claude/Python pipeline.
Main entry points: SKILL.md regime skill · markov_regime.py Bull/Bear/Sideways labels · plugin.json Plugin manifest · marketplace.json Marketplace manifest
Components 17
Claude Code Plugin
- Marketplace manifest · Publishes the plugin to Claude Code marketplaces.
.claude-plugin/marketplace.json - Plugin manifest · Maps the installed plugin to its skill content.
.claude-plugin/plugin.json - regime skill · Defines invocation, inputs, JSON output, and composition behavior.
skills/regime/SKILL.md - Agent or trading workflow · Uses the result as a signal, confirmation filter, or tail-risk gate.
Local Analysis Pipeline
- Regime analysis engine · Local executable pipeline for ticker or CSV analysis.
scripts/markov_regime.py - Ticker input
- Price CSV · User-provided date and close series.
- yfinance · Fetches ticker price history from the local runtime.
- Price series
- Bull/Bear/Sideways labels · Classifies rolling returns using configurable lookback and thresholds.
scripts/markov_regime.py - Transition model · Builds the 3×3 maximum-likelihood transition matrix.
scripts/markov_regime.py - Forecast and baseline · Uses matrix powers for n-step forecasts and computes stationary distribution.
scripts/markov_regime.py - Directional signal · Reports bull-minus-bear signal, conviction, and regime stickiness.
scripts/markov_regime.py - Walk-forward backtest · Avoids lookahead bias and reports Sharpe ratio and maximum drawdown.
scripts/markov_regime.py - Optional HMM fit · Uses hmmlearn when installation succeeds; otherwise degrades gracefully.
scripts/markov_regime.py
Alternate Delivery
- Manual bootstrap guide · Instructs Claude Code to create an equivalent local skill installation.
markov-hedge-fund-method.md - TradingView indicator · Independent chart-side regime and transition visualization.
pine-script/markov-hedge-fund-method.pine
Connections 16
- Marketplace manifest → Plugin manifest: publishes
- Plugin manifest → regime skill: installs
- Agent or trading workflow → regime skill: invokes /regime
- regime skill → Regime analysis engine: orchestrates
- Ticker input → yfinance: selects
- yfinance → Price series: fetches history
- Price CSV → Price series: provides
- Price series → Bull/Bear/Sideways labels: rolling returns
- Bull/Bear/Sideways labels → Transition model: historical states
- Transition model → Forecast and baseline: transition matrix
- Forecast and baseline → Directional signal: probabilities
- Directional signal → Agent or trading workflow: JSON output
- Bull/Bear/Sideways labels → Walk-forward backtest: walk-forward states
- Transition model → Walk-forward backtest: strategy evaluation
- Price series → Optional HMM fit: optional fit
- Manual bootstrap guide → regime skill: alternate installation