Regime logo

Regime

Organization
jackson-video-resources
regime

Detect the market regime (Bull / Bear / Sideways) for ANY asset and turn it into a tradeable signal or a risk filter. Use this whenever the user wants regime detection, a regime-aware confirmation on an existing strategy, a regime risk gate, regime-based position sizing, a Markov transition matrix, n-step regime forecasting, a stationary regime mix, or a no-lookahead walk-forward regime backtest — on a ticker (via yfinance) or on the user's own CSV price series. Composes into any existing trading agent or strategy without rewriting it. Framework by Roan (@RohOnChain).

Overview

Publisherjackson-video-resources
Repositorymarkov-hedge-fund-method
Skill nameregime
Stars
490
Forks
228
Bundled files
Instructions only
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by jackson-video-resources on GitHub. Read the source before you install it.

Installation

Install the Regime AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/jackson-video-resources/markov-hedge-fund-method/tree/main/skills/regime
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/jackson-video-resources/markov-hedge-fund-method.git /tmp/markov-hedge-fund-method
mkdir -p .claude/skills
cp -r /tmp/markov-hedge-fund-method/skills/regime .claude/skills/regime
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Regime in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Regime on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Regime is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Regime — Markov regime detection for any asset

This skill answers one question for any asset: what regime are we in, how sticky is it, and what does that imply for risk and direction? It's built to slot into a trading agent the user already has — as a confirmation layer, a signal, or a risk gate — without them rewriting their strategy.

Framework: Roan (@RohOnChain). Refactored into this plugin by Lewis Jackson. Backtests are historical, not forward-looking.

How to invoke

One command. It takes EITHER a ticker OR the user's own CSV, so it drops into any pipeline regardless of asset:

bash
# any ticker yfinance knows (stocks, ETFs, crypto, FX, futures):
uv run ${CLAUDE_PLUGIN_ROOT}/scripts/markov_regime.py --ticker BTC-USD --json

# the user's own price file (their data, their asset, their pipeline):
uv run ${CLAUDE_PLUGIN_ROOT}/scripts/markov_regime.py --csv ./my_prices.csv --json
  • Drop --json for the on-camera pretty terminal output (matrix, persistence diagonal, stationary mix, walk-forward Sharpe + max DD, HMM line).
  • --csv needs only a date column and a close column. It auto-detects common names (date/time/timestamp, close/adj close/price/last); if there's exactly one numeric column it uses that. No reformatting required.
  • Defaults: --window 20, --threshold 0.05 (±5%), --years 10, --min-train 252. All overridable. --no-hmm skips the HMM.
  • First uv run resolves dependencies once (~10–20s), then it's instant.

The JSON contract (every field)

--json prints exactly one JSON object to stdout and nothing else. On failure it prints {"error": "..."} and exits non-zero. Fields:

FieldTypeMeaning
sourcestrthe ticker or CSV path analysed
rowsintnumber of price rows used
date_start, date_endstrISO dates of the window
paramsobjwindow, threshold, min_train actually used
stateslist["Bear","Sideways","Bull"] — fixed index order 0,1,2
current_regimestrthe regime as of the last bar
next_state_probabilitiesobjbear/sideways/bull — P(next | current)
signalfloatbull_prob − bear_prob in [-1, 1]. >0 long bias, <0 short bias, magnitude = conviction
transition_matrix3×3 listrow = from-state, col = to-state, rows sum to 1
persistence_diagonalobjbear/sideways/bull — P(stay in same regime). High = sticky regime
stationary_distributionobjbear/sideways/bull — long-run fraction of time in each regime, sums to 1
walk_forwardobjsharpe, max_drawdown, n_trades from a re-estimated-every-step, no-lookahead backtest. sharpe/max_drawdown may be NaN if history is too short
hmmobjavailable: true → regimes (label, latent_state, mean_daily_return) + caveat. available: false → reason (graceful degrade — everything else is still valid)
framework, disclaimerstrattribution + "historical, not forward-looking"

signal and current_regime are the two fields most strategies consume. stationary_distribution is the one most risk layers consume.

Composition — slot it into what the user already has

The user already has a trading agent or strategy on some asset. This skill is a layer they add, not a system they adopt. Run it, read one or two fields, gate their existing logic. Three patterns:

(a) Regime confirmation on an existing momentum/strategy

The user has entry logic that already fires. Wrap it: only take longs when the regime agrees, only short when it disagrees.

python
import json, subprocess
r = json.loads(subprocess.check_output(
    ["uv","run",f"{PLUGIN}/scripts/markov_regime.py","--ticker","SPY","--json"]))

if my_strategy_says_long and r["signal"] > 0:
    enter_long()          # momentum + regime agree → take it
elif my_strategy_says_long and r["signal"] <= 0:
    skip()                # momentum says go, regime says don't → stand down

One line of gating. Their strategy is untouched; the regime just vetoes trades that fight the prevailing chain.

(b) Stationary distribution as a tail-risk / position-size filter

The stationary mix is the asset's long-run baseline. A high baseline Bear share means this asset structurally spends a lot of time in drawdown — size down.

python
bear_baseline = r["stationary_distribution"]["bear"]
size = base_size * (1.0 - bear_baseline)      # heavier bear regime → smaller bets
# or hard gate: if bear_baseline > 0.40: size = 0   # too tail-heavy to trade

No new model. The user keeps their sizing logic and scales it by a single number that reflects how regime-dangerous the asset actually is.

(c) Standalone signal

No existing strategy needed. The signal field is already a direction + conviction in [-1, 1]:

python
position = r["signal"]        # +0.6 → 60% long; -0.4 → 40% short; ~0 → flat

Sanity-check it first with the printed walk-forward Sharpe + max drawdown (run without --json to see them on screen) before sizing real capital.

Notes

  • Asset-agnostic by design. --ticker for anything yfinance covers; --csv for the user's own data on any asset/timeframe their pipeline produces. The math is identical either way.
  • No lookahead. The walk-forward refits the matrix using only past data at every step (incremental O(n), bit-identical to a from-scratch rebuild).
  • HMM degrades gracefully. If hmmlearn can't compile (e.g. Windows without MSVC), hmm.available is false with a reason and every other field is still correct. HMM states are labelled by ascending mean return, so a positive "Bear" mean just means the worst latent state was still net-positive over that window.
  • Defaults match the on-camera demo and the Pine Script bonus (window 20, ±5%). Use --threshold 0.02 to reproduce the tighter labelling from the original onboarding prompt.

Frequently asked questions

What does the Regime AI skill do?

Detect the market regime (Bull / Bear / Sideways) for ANY asset and turn it into a tradeable signal or a risk filter. Use this whenever the user wants regime detection, a regime-aware confirmation on an existing strategy, a regime risk gate, regime-based position sizing, a Markov transition matrix, n-step regime forecasting, a stationary regime mix, or a no-lookahead walk-forward regime backtest — on a ticker (via yfinance) or on the user's own CSV price series. Composes into any existing trading agent or strategy without rewriting it. Framework by Roan (@RohOnChain).

Why use Regime on TypingMind?

Because you install it once and use it with any model. Regime is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Regime in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/jackson-video-resources/markov-hedge-fund-method/tree/main/skills/regime. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Regime?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Regime?

As many as you like. As long as a model supports skills, you can use Regime with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Regime AI skill free?

It is published on GitHub by jackson-video-resources. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇