Logo vun Regime

Regime

Organisatioun
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).

Iwwersiicht

Editeurjackson-video-resources
Repositorymarkov-hedge-fund-method
Skill-Nummregime
Stären
490
Forks
228
Matgeliwwert Fichieren
Nëmmen Instruktiounen
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • Alles an den Instruktiounen

    Alles, wat de Modell brauch, steet an den Instruktiounen — keng zousätzlech Dateien ze synchroniséieren.

  • Open Source

    Vum jackson-video-resources op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Regime an TypingMind, fir e mat all LLM ze benotzen, oder füügt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vun GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier hei drënner an a bestätegt.
    https://github.com/jackson-video-resources/markov-hedge-fund-method/tree/main/skills/regime
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill afügen → Vu GitHub-URL, pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an de Skill-Verzeechnes vun deem KI-Agent.

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
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert Regime an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet Regime automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Regime net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Keys.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

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.

Heefeg gestallte Froen

Wat mécht de KI-Skill 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).

Firwat Regime op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Regime besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt amplaz vun engem Abonnement pro Benotzerplaz. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Regime an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/jackson-video-resources/markov-hedge-fund-method/tree/main/skills/regime an. TypingMind liest d'Datei SKILL.md an installéiert de Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen Regime benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat Regime benotzen?

Esou vill Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Regime domat benotzen – GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama a méi – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill Regime gratis?

De Skill gëtt vum jackson-video-resources op GitHub publizéiert. Kuckt am Repository no de Lizenzbedéngungen. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbaart Pak vun Instruktiounen, dat engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt en nokënnt a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a keng Lafzäitëmfeld a funktionéiere mat all Modell.

All weisen

Elo Ären eegene KI-Workspace ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇