Most trading tools try to answer which way? This one answers how much?
GARCH estimates the magnitude of tomorrow's potential move—not its direction. This project turns that forecast into a calm/normal/storm regime and a practical position-size multiplier.
[!IMPORTANT]
GARCH does not predict whether price will rise or fall. It forecasts volatility. Entries and exits must come from your strategy.
What you get
- Walk-forward GARCH(1,1): forecasts are produced using only information available at the time.
- One-day volatility forecast: daily and annualized values.
- Market weather: calm, normal, or storm based on the trailing volatility percentile.
- Volatility-targeted sizing:
target volatility ÷ forecast volatility, capped between 0.25x and 2.0x.
- Honest strategy comparison: the same signals at fixed size and volatility-targeted size.
- Useful risk statistics: CAGR, annualized volatility, Sharpe ratio, maximum drawdown, worst month, and final equity.
- Two data paths: Yahoo Finance ticker or a local price CSV.
- TradingView companion: the Pine Script Storm Gauge for chart-level context.
Quick start
Option A — install as a Claude Code plugin
Prerequisites: Claude Code and uv.
Run these commands inside Claude Code:
/plugin marketplace add Miles-Deutscher/Garch-Method
/plugin install garch-method@garchmethod
Then ask naturally:
What's the volatility forecast for BTC-USD?
How large should my SPY position be at a 15% volatility target?
Compare my strategy with and without volatility targeting.
Claude loads the skill and runs the appropriate tool. No API key, paid data account, or sudo is required.
Option B — run the Python tools directly
git clone https://github.com/Miles-Deutscher/Garch-Method.git
cd Garch-Method
uv run scripts/garch_forecast.py --ticker BTC-USD --json
Dependencies are declared inside each script and resolved by uv on the first run.
Five-minute tutorial
1. Forecast tomorrow's volatility
Crypto example:
uv run scripts/garch_forecast.py \
--ticker BTC-USD \
--periods-per-year 365 \
--json
Equity example:
uv run scripts/garch_forecast.py \
--ticker SPY \
--periods-per-year 252 \
--json
The result includes:
{
"asset": "BTC-USD",
"as_of": "YYYY-MM-DD",
"forecast_vol_daily_pct": 2.4,
"forecast_vol_annualized_pct": 45.8,
"vol_percentile_1y": 78.0,
"regime": "storm",
"note": "GARCH forecasts magnitude (volatility), not direction."
}
The numbers above are illustrative; your result depends on the latest available data.
2. Convert the forecast into a position size
uv run scripts/vol_target.py \
--ticker SPY \
--target-vol 15 \
--periods-per-year 252 \
--json
The core calculation is intentionally simple:
position multiplier = target annualized volatility / forecast annualized volatility
Examples:
| Forecast volatility | Target volatility | Raw multiplier | Applied size |
|---|
| 30% | 15% | 0.50x | 0.50x |
| 15% | 15% | 1.00x | 1.00x |
| 5% | 15% | 3.00x | 2.00x cap |
The floor is 0.25x; the maximum is 2.00x.
3. Compare fixed sizing with volatility targeting
Run the included EMA 9/21 crossover demonstration:
uv run scripts/compare.py \
--ticker BTC-USD \
--target-vol 58 \
--periods-per-year 365 \
--chart equity_comparison.png \
--json
This applies identical signals to two portfolios:
- Fixed size: every position is
1x.
- Vol-targeted: each position uses the forecast-based multiplier.
The comparison is designed to answer a narrow question: did sizing improve the strategy's risk profile? Always inspect maximum drawdown and worst month alongside returns.
Use your own data
Price CSV
Provide at least roughly 510 daily observations. Column names are matched case-insensitively.
date,close
2023-01-01,16547.50
2023-01-02,16611.20
2023-01-03,16669.10
Run:
uv run scripts/garch_forecast.py \
--csv my_prices.csv \
--periods-per-year 365 \
--out-csv volatility_series.csv \
--json