I Re-Created A Quant Trading Strategy With Claude Code (Insanely Cool)
I Re-Created A Quant Trading Strategy With Claude Code (Insanely Cool) — Lewis Jackson
ELI5 / TLDR
Retail traders trade on vibes. Quants, allegedly, turn vibes into numbers. Lewis Jackson found a quant’s framework on trading Twitter, boiled it into ten steps, and packaged it as a Claude Code skill plus a TradingView indicator. The core idea: label every day as bull, bear, or sideways based on rolling 20-day returns, count how often the market transitions between states, build a 3×3 probability matrix, and trade the gap between tomorrow’s bull and bear odds. He then uses AI to install the whole pipeline and run walk-forward backtests. Interesting as a regime-model primer and a Claude Code demo. Not a hedge fund secret, and he never shows whether it actually makes money.
The Full Story
The gap between retail and institutional trading
Jackson opens with a familiar contrast. Day traders and even many professionals operate on charts — trend lines, indicators, gut feel. Hedge fund quants, he claims, do something else entirely: they quantify sentiment into measurable states and trade probabilities, not patterns.
The source material is a Twitter thread by “Rowan,” a quant who published what Jackson calls the “hedge fund method.” Jackson’s video job is to explain all ten elements, convert them into an AI-readable skill, and hand you copy-paste prompts to run it yourself.
Ten elements, starting with states
1. States. Every day gets classified into one of three regimes based on cumulative return over the prior 20 trading days:
- Bull: +5% or more
- Bear: −5% or worse
- Sideways: everything in between
Think of it like a thermometer with only three readings instead of a continuous number. Crude, but it forces the market into discrete buckets quants can count.
2. Label the full history. Run that classification across every day of an asset’s life. From day 20 onward, each date carries a state label. Bitcoin’s entire price history becomes a sequence: bull, bull, sideways, bear, bear, bull…
3. The Markov property. Here’s the conceptual hinge. The probability of where the market goes next depends only on where it is now, not on the full path that got you here. Jackson uses a road-trip analogy: the route from Ohio to New York doesn’t care that you started in Little Rock. Past states matter only insofar as they produced today’s state.
This is standard Markov chain thinking — tomorrow’s distribution is conditioned on today’s state, not on last month’s drama.
4. The transition matrix. Count every historical state change. Bull → sideways happened X times. Bear → bull happened Y times. All nine combinations get tallied and converted to percentages. The result is a 3×3 grid: rows are today’s state, columns are tomorrow’s likely state. Each row sums to 100%.
5. Persistence (“stickiness”). The diagonal cells — bull→bull, bear→bear, sideways→sideways — measure how likely a regime is to persist. Bull and bear states tend to be “sticky.” This is where “the trend is your friend” gets a numerical backbone: if you’re in a bull state today, the highest single probability for tomorrow is usually another bull state. Not certainty — just the modal outcome.
Extending the forecast
6. Matrix squaring. Want a two-day forecast? Multiply the transition matrix by itself. Three days? Cube it. Each power extends the horizon. A bull-today → bull-in-two-days probability of 80% × 80% = 64%.
7. Stationary distribution. Keep raising the matrix to high powers (say, 28 days) and the probabilities flatten into near-uniform mush. Every outcome gets roughly the same tiny percentage. The signal dies at long horizons — which is actually the point. Short-horizon regime persistence is where the model has something to say; long-horizon forecasts converge to “we don’t know.”
From math to trades
8. Signal generation. After all that machinery, the actual trade signal is almost insultingly simple:
Bull probability tomorrow − Bear probability tomorrow = signal
Example: 65% bull, 20% bear → signal of +45% → go long. The magnitude scales position size. Negative signal → short. Sideways probability is implicitly the remainder. Each fund would calibrate how aggressively to size off the differential, but the direction is just signed probability gap.
9. Walk-forward backtesting. Standard backtests are contaminated by lookahead: you build a strategy using all historical data, then “test” it on 2020 — but the model already saw 2020’s outcomes when you fitted it. Walk-forward testing recalculates the entire matrix each day using only data available up to that point. Computationally brutal. Jackson notes this used to be painful; AI makes it tractable. His explanation here is hand-wavy, but the concept is sound and important.
10. Hidden Markov Models (HMM). The 5%/−5% thresholds are arbitrary human choices — the weak link in an otherwise mechanical system. HMMs fix this by letting the data discover regimes without preset labels. Jackson’s babysitter analogy: watch the children (price data) for a while, then assign personalities (states) based on observed behavior, not preconceived rules. When the hand-labeled states and the HMM-discovered states agree, that’s your confirmation signal.
The Claude Code implementation
The second half is a live tutorial. Jackson’s GitHub repo contains:
- A Claude Code skill — paste a prompt, type “go,” and it installs a
/markovcommand that runs Rowan’s “observable Markov regime model” on any ticker. Demo runs on SPY’s 10-year chart in about two minutes. - A Pine Script indicator for TradingView — visualizes the 3×3 matrix on any chart. On Bitcoin at recording time: 29% bull, 42% bear, 29% sideways for tomorrow, consistent with recent bearish stickiness.
The workflow is genuinely neat as an AI-assisted quant prototyping demo. Copy prompt → install skill → /markov on your strategy → get regime analysis. The Pine Script gives you a live dashboard without leaving your chart.
Key Takeaways
- Regime models beat chart patterns for systematic trading. The whole framework replaces “this looks bullish” with “given we’re in a bull state, there’s an X% chance of bull tomorrow.”
- The transition matrix is the engine. Count state changes, convert to probabilities, read off tomorrow’s distribution from today’s row. Matrix powers extend the horizon; high powers reveal the stationary distribution (i.e., long-term uncertainty).
- Signal = bull prob − bear prob. Complex backend, one-line frontend. Position size scales with signal magnitude.
- Walk-forward backtesting matters. Recalculate the matrix daily with only past data. Without it, your backtest is lying to you.
- HMMs remove arbitrary thresholds. Let the data define what “bull” means instead of picking ±5% by hand.
- Claude Code as quant tooling is real. Packaging a multi-step statistical pipeline as an installable skill is a practical pattern — not just for trading, but for any repeatable analytical workflow.
Claude’s Take
This is a well-produced explainer of a legitimate quant concept (Markov regime switching) wrapped in YouTube packaging that oversells it as “hedge fund secrets.” Real quant shops do use regime models, but they’re one tool among hundreds, heavily customized, and tested against transaction costs, slippage, and capacity constraints none of which appear here.
Jackson is honest about not fully understanding walk-forward backtesting, which is a yellow flag for a video promising hedge-fund-grade methodology. The HMM section is conceptually right but glosses over estimation, model selection, and the fact that three states is itself a choice. The ±5% thresholds are reasonable starting points, not discoveries.
What’s genuinely useful: (a) a clear intro to Markov transition matrices for anyone who’s only ever drawn trend lines, and (b) a concrete demonstration that Claude Code skills can encapsulate non-trivial statistical pipelines. The GitHub artifacts are free and the install demo works. Whether the strategy makes money after fees is never tested or shown — and that’s the part that would actually matter.
Score: 6/10. Solid educational packaging, real underlying math, but marketed harder than validated. Good if you want to understand regime models or see Claude Code skills in action. Not good if you want a proven edge.
Further Reading
- “Advances in Financial Machine Learning” — Marcos López de Prado (walk-forward testing, backtest overfitting, why most retail backtests are fiction)
- “Quantitative Trading” — Ernest Chan (accessible intro to regime detection and systematic strategy design)
- Rowan’s original work — referenced as “Rowan Chain” / observable Markov regime model on GitHub (linked in the video description; Jackson’s repo repackages it)