Building A Quant Trading Strategy With Claude Code (GARCH Method)

@milesdeutscher
İNGILIZCE1 gün önce · 21 Tem 2026
186K
285
36
15
768

TL;DR

Miles Deutscher demonstrates how to use Claude Code to automate the GARCH model, a Nobel-Prize-winning volatility framework used by quant desks to optimize position sizing and reduce market risk.

This is not something you will find anywhere else on 𝕏.

I recently used Claude Code to build and automate a legitimate quant desk trading strategy - and it's genuinely insane.

This quant strategy is backtested on 15+ years of price data across the Nasdaq, Bitcoin, and more, and is one of the most used trading strategies by real quant desks.

It's called the GARCH model, and the economist behind the calculation won a Nobel Prize for it in 2003 - it's that powerful.

In this article, I'm revealing the entire process for how I automated this insane quant trading strategy using Claude Code.

To give back to the trading community, I open-sourced the GitHub repo, which contains the entire methodology behind this trading strategy - including a reusable Claude Skill, full TradingView installation instructions, & more.

In Section V (Installing & Testing the Claude Skill) you'll find the GitHub link you can use now to run this strategy for yourself in the live markets.

Miles Deutscher - inline image

* Open-source GARCH Trading Strategy

Table of Contents

I: wtf is a quant?

II: Building Quant Models 101

III: The GARCH Model

IV: Calculating Real Positions

V: Installing & Testing the Claude Skill

VI: Importing Into TradingView

I truly believe this is one of my best finance x AI articles ever - be sure to bookmark this so you don't lose it.

I: wtf is a quant?

Ok. Before we dive into the actual strategy, we need to define what a "quant" is because the word gets thrown around constantly, and nobody explains what it actually means.

Quant is short for quantitative analyst.

In short, these are people who typically come out of advanced mathematics, physics, or computer science, and funds recruit them on some of the highest salaries in all of finance.

As a quant, their job is to build financial models that represent a market view and turn that view into a trading system with real constraints attached.

An example: Say your market view is "the market is getting dangerous, I should be more careful."

That is simply an opinion.

A quant cannot trade an opinion, so they break it into pieces that can be measured. How dangerous, exactly? Measure it against the last year of data. How much more careful should we be? Divide the risk you can tolerate by the risk the market is currently paying out. What if I am wrong?

In short, a quant's job is to build quantitative \measurable\ models and systems based on different market variables.

Miles Deutscher - inline image

wtf is a quant?

II: Building Quant Models 101

Most retail traders open a chart and see price (where it has been, where it might go) - and their entire read is directional.

A quant opens the same chart and reads a completely different set of variables.

Quants are not looking to predict price direction, instead, they are often looking at:

  • Volatility
  • Value at risk
  • Position sizing
  • Exposure
  • Expected moves

Then, they compress all of these various variables into a single score/calculation.

For the sake of this article, I'm going to call this the "violence" score - but I am aware that things are more nuanced than that.

For example:

March 2020 S&P500 (-34% market crash)

Miles Deutscher - inline image

March 2020 crash

FTX Collapse 2022 $BTC (-25% in a single week)

Miles Deutscher - inline image

FTX collapse

These are two examples of pretty "violent" market trading days (high volatility).

A quant analyst will look at both of these violent price movements and come up with a score that can be used to measure both (which is exactly what the GARCH framework does - more on this later).

On a typical day, there is about a ~10% chance of a violent move in $BTC. On a day after ones like the FTX crash, that probability triples to ~30% (these numbers are backtested from 15+ years of Bitcoin price data).

This model isn't perfect, but it gives you a rough framework for how a quant would actually build a tradeable model based on real market variables.

Quant analysts (and the GARCH model) are often looking for predictable market volatility that can be used to manage portfolio risk.

III: The GARCH Model

We have established that market violence is predictable. The question now becomes how do we actually measure and forecast it?

This is where the Nobel-Prize-winning calculation by Robert F. Engle comes in.

Robert F. Engle originally developed the "ARCH" framework that was then extended by his student Tim Bollerslev to the "GARCH" framework we know today that many quant desks run.

Miles Deutscher - inline image

GARCH market volatility model

How the GARCH calculation works

GARCH forecasts tomorrow's market violence as the sum of three things:

  1. Base level market movement

Every asset carries a baseline amount of movement.

For example, Bitcoin's is higher than the S&P's, and that never really changes.

  1. Yesterday's shock

How hard did the market actually move in the last session?

  1. Yesterday's volatility level

Where was volatility already sitting before that move happened?

By adding those three things together, you have a forecast for tomorrow's potential market violence - and that is the entire model.

Keep in mind, with these three market variables, the GARCH model forecasts how violent the market may be in the future, but it doesn't give us a directional bias (long/short).

IV: Calculating Real Positions

This is where the GARCH volatility forecast becomes tradeable.

The logic runs like this:

The risk on any trade is your position size multiplied by the market's violence - you cannot control market violence, so instead, you control position size.

This is broken into three steps:

Step One: Set Your Account Drawdown Limit

Decide the annual swing you are willing to tolerate on your account -institutional desks typically run ~15%.

Step Two: Pull the Violence Score

Pull the current violence score from the GARCH model.

As I write this, the Nasdaq is running at roughly 30% annualised.

Miles Deutscher - inline image

Violence score calculation

Step Three: Calculate

Divide your account drawdown limit by the model score (15/30 = 0.5).

If a trade signal fires today, that means it would get half your normal position size (0.5).

For example, on a $10,000 baseline position, that is $5,000.

Where the GARCH model falls short

This model will never call a top or a bottom. In fact, it contains zero directional information at all, and if a crash erupts out of a genuinely calm market period, this will not save you, and in theory, you would catch it at full size.

I am not claiming this quant model removes risk - but I am saying it is the best starting point I have found for thinking about risk the way professionals actually do.

And to be clear, actual entries and exits are determined by another trading department within financial trading desks - a quant's job is simply to develop predictable, repeatable frameworks like the GARCH model to help manage risk over time.

V: Installing & Testing the Claude Skill

I encoded this entire quant risk framework into a reusable Claude Skill that you can install to help manage your own portfolio's risk.

Here's a step-by-step on how to install it - there are two ways to install it:

Method One: Plugin command

Miles Deutscher - inline image

Install

Paste the install command into Claude Code and it will run the plugin install automatically.

Miles Deutscher - inline image

example

Method Two: Manual file config.

If you want to see the strategy written line by line, open garchmethod.md in the repo, copy the whole file, and paste it into Claude Code.

It will fetch the skill files from the repo and verify the strategy for you.

Miles Deutscher - inline image

manual config. file

You do not need both methods - I am just showing you both so you can choose.

Once it is installed, you can just talk to it, and it runs using the exact GARCH model outlined above.

Example prompts

"What's the volatility forecast on Bitcoin?"

"Explain what the current volatility forecast means on $BTC in simple terms and how it should impact my Bitcoin position sizing."

"Help me size my S&P500 position according to current market volatility"

Miles Deutscher - inline image

example

Backtesting the strategy

I backtested the same trading strategy two ways. One with fixed position sizing, and one with the GARCH position sizing framework.

The strategy itself was a simple EMA cross, running on 15 years of Bitcoin data. I ran the same entries, same exits, and the same signals in both.

Over the 15-year timeframe, the GARCH framework ended with a total portfolio equity of $21,205, while the fixed position sizing ended at $17,957.

The important part is that the GARCH framework took significantly fewer drawdowns, and overall, less market risk to achieve a greater portfolio balance.

Miles Deutscher - inline image

backtesting (real results)

Miles Deutscher - inline image

backtesting (real results)

I conducted many other such backtests where the GARCH framework was a clear winner, and this is why this quant framework is so powerful.

VI: Importing Into TradingView

This is the last piece that puts the whole framework on your chart as a live number.

Inside the repo there is a Pine Script folder.

Open it and copy the entire file.

Miles Deutscher - inline image

Pine script

Then go into TradingView, open the Pine Editor, paste it in, hit enter, and refresh.

This will load the entire indicator and calculation score into your live charts.

Miles Deutscher - inline image

Importing into TradingView

Once added, you'll see a live "Storm Gauge" calculation in your TradingView charts (the GARCH volatility calculation in real time).

Miles Deutscher - inline image

Storm Gauge

Closing

I hope you found this quant framework valuable - I genuinely haven't seen anybody else use AI in the markets like this.

If you did find this valuable, be sure to follow me here @milesdeutscher - every single week, I post articles breaking down how I'm using AI to gain an edge in the financial markets.

For deeper AI insights, follow me over on @aiedge_.

If you enjoy written content, feel free to subscribe to my free market newsletter.

Every single week, we publish free market research, real finance x AI workflows, & more.

https://newsletter.milesdeutscher.com.au/

Miles Deutscher - inline image

Market newsletter by Miles

100% free, no spam ever & unsub anytime

Thank you for making it this far.

- Miles

Tek tıkla kaydet

YouMind ile viral makaleleri AI derin okumayla incele

Kaynağı kaydedin, odaklı sorular sorun, argümanı özetleyin ve viral bir makaleyi tek bir AI çalışma alanında yeniden kullanılabilir notlara dönüştürün.

YouMind'ı keşfet
Üreticiler için

Markdown'ınızı temiz bir 𝕏 makalesine dönüştürün

Kendi uzun yazılarınızı yayımlarken görselleri, tabloları ve kod bloklarını 𝕏 için biçimlendirmek zahmetlidir. YouMind, eksiksiz bir Markdown taslağını temiz ve hemen paylaşılabilir bir 𝕏 makalesine dönüştürür.

Markdown'dan 𝕏'e deneyin

Çözülecek daha fazla kalıp

Son viral makaleler

Daha fazla viral makale keşfet