Downloads · 30 days
57
48% of all-time downloads
SanguineLithium/spy-gru20-volatility-forecast
spy-gru20-volatility-forecast is a machine learning model from SanguineLithium. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for keras.
A compact recurrent neural-network release that forecasts the annualized volatility magnitude of SPY over the next five trading days using only daily adjusted OHLCV-derived information available through market close o…
Downloads · 30 days
57
48% of all-time downloads
All-time downloads
120
Public
Repo size
645 KB
Likes
0
Public
Click a slice to open those files.
.keras644 KB · 95%
From the Hugging Face model README
A compact recurrent neural-network release that forecasts the annualized volatility magnitude of SPY over the next five trading days using only daily adjusted OHLCV-derived information available through market close on day t.
This repository packages the exact three final Keras checkpoints and exact StandardScaler artifact produced by the accepted ARIN 470 experiment. The release does not retrain, convert, quantize, or reserialize those files.
For daily adjusted log return r_t = ln(Close_t / Close_{t-1}), the target is:
sqrt((252 / 5) * sum(r_{t+i}^2 for i = 1..5))
The output is a decimal annualized five-trading-day forward volatility proxy. For display as a percentage, multiply by 100. It is not presented as high-frequency realized volatility, a price-direction forecast, a trading signal, or investment advice.
| Artifact | Purpose |
|---|---|
models/final_GRU_20_seed_42.keras | Final GRU-20 fit, seed 42 |
models/final_GRU_20_seed_52.keras | Final GRU-20 fit, seed 52 |
models/final_GRU_20_seed_62.keras | Final GRU-20 fit, seed 62 |
preprocessing/final_standard_scaler.joblib | Final training-only feature scaler |
config/feature_spec.json | Exact feature order and formulas |
config/model_manifest.json | Architecture, hashes, environment, data/evaluation identity |
evaluation/holdout_metrics.json | Structured accepted holdout results |
CHECKSUMS.sha256 | SHA-256 integrity record |
The three checkpoints are repeated final fits, not three members of a separately validated ensemble. The experiment's primary neural summary is the arithmetic mean of the three seed-level error metrics.
Input (20 steps × 7 features)
→ GRU(64)
→ Dropout(0.20)
→ Dense(16, ReLU)
→ Dense(1, Softplus)
The 18-epoch budget was frozen as the median of the selected candidate's Fold-3 best epochs: 4, 25, 18 → 18.
The model consumes the latest 20 valid feature rows in this exact order:
log_returnabs_returnlog_hl_rangelog_volume_changereturn_5dvol_5d_trailingvol_20d_trailingThe exact formulas and scaler contract are in config/feature_spec.json. The raw input is adjusted daily Open, High, Low, Close, and Volume data, ordered by trading date. Use completed daily bars only.
Four recurrent candidates were evaluated across three forward development folds and three seeds each, producing 36 candidate/fold/seed fits.
| Candidate | Mean validation MAE | 1% practical-tie band | Parameters |
|---|---|---|---|
| LSTM-20 | 0.048630 | Yes | 19,489 |
| GRU-20 | 0.048848 | Yes | 15,073 |
| GRU-60 | 0.048917 | Yes | 15,073 |
| LSTM-60 | 0.050098 | No | 19,489 |
Selection used the predeclared rule: minimum mean validation MAE; candidates within 1% relative MAE were treated as practically tied, then fewer trainable parameters, then shorter sequence length. That rule selected GRU-20.
Final holdout: 1,641 daily anchors, 2019-06-17 through 2025-12-23.
| Model | MAE | RMSE |
|---|---|---|
| GRU-20 seed 42 | 0.052552 | 0.092085 |
| GRU-20 seed 52 | 0.052575 | 0.093253 |
| GRU-20 seed 62 | 0.051968 | 0.089546 |
| Neural mean across seed metrics | 0.052365 | 0.091628 |
| Persistence | 0.063335 | 0.099593 |
| GARCH(1,1), Student-t | 0.063054 | 0.099162 |
Seed variability for the reported neural summary:
Relative to the baselines, the mean neural metrics were approximately:
A predeclared every-fifth-anchor sensitivity retained the same overall ordering. Dependence-aware paired stationary-bootstrap intervals for neural-minus-baseline MAE loss differentials were entirely below zero in both planned comparisons:
The 97.5% interval was used per pair as the Bonferroni-adjusted component of a 95% familywise procedure across the two planned comparisons. Full structured results are in evaluation/holdout_metrics.json.
The final scaler was fitted on 6,617 unique calendar feature rows from 1993-03-01 through 2019-06-07. The final holdout begins 2019-06-17. The stored scaler was independently reconstructed during forensic review and its means/scales matched the expected training-only fit population.
No feature clipping is used.
Install the pinned release environment:
pip install -r requirements.txt
Run an integrity check first:
python examples/verify_artifacts.py --load
Then provide a CSV containing completed adjusted daily bars with columns:
Date,Open,High,Low,Close,Volume
and run one checkpoint:
python examples/predict_from_ohlcv.py --csv /path/to/spy_adjusted_ohlcv.csv --seed 42
Example output shape:
{
"ticker": "SPY",
"as_of": "YYYY-MM-DD",
"checkpoint_seed": 42,
"forecast_horizon_trading_days": 5,
"predicted_annualized_volatility": 0.0796,
"predicted_annualized_volatility_pct": 7.96,
"trailing_5d_volatility": 0.0612,
"trailing_5d_volatility_pct": 6.12
}
The numeric example above is illustrative of the response schema; current forecasts depend on the supplied completed market history.
After this directory is uploaded to a model repository:
python examples/predict_from_hub.py \
--repo-id YOUR_USERNAME/spy-gru20-volatility-forecast \
--csv /path/to/spy_adjusted_ohlcv.csv \
--seed 42
The script uses huggingface_hub.snapshot_download() and then loads the unchanged .keras checkpoint and scaler locally.
This release is intended for:
It is not intended to provide:
The executed experiment used a frozen SPY daily adjusted OHLCV snapshot obtained through Yahoo Finance / yfinance, spanning 1993-01-29 through 2025-12-31 (8,288 raw rows). The raw dataset is not redistributed in this model repository. The release manifest records both the executed DataFrame hash and the local frozen CSV file SHA-256 for provenance.
The release-critical model/scaler hashes are recorded in config/model_manifest.json and CHECKSUMS.sha256. examples/verify_artifacts.py verifies the packaged bytes before optional deserialization.
The accepted execution environment recorded:
The model repository intentionally contains the frozen inference artifacts and concise evaluation evidence rather than the full training dataset or entire development notebook.
No explicit model license has been selected in this release package. Do not infer reuse permissions from public availability alone. Add a license before public release if broader reuse is intended.
Developed as an ARIN 470 deep-learning project. The experiment asked whether a deep recurrent sequence model using only information available through market close on day t could forecast the magnitude of SPY volatility over the next five trading days more accurately than persistence and a conventional GARCH baseline under forward-only evaluation.