https://github.com/bdr-pro/iv-stock-predictor
Delta IV Forecasting with XGBoost & LSTM (Stock Options)
https://github.com/bdr-pro/iv-stock-predictor
machine-learning stock-price-prediction
Last synced: about 1 year ago
JSON representation
Delta IV Forecasting with XGBoost & LSTM (Stock Options)
- Host: GitHub
- URL: https://github.com/bdr-pro/iv-stock-predictor
- Owner: BDR-Pro
- License: gpl-3.0
- Created: 2025-05-18T10:39:04.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-18T10:40:49.000Z (about 1 year ago)
- Last Synced: 2025-05-18T11:37:08.623Z (about 1 year ago)
- Topics: machine-learning, stock-price-prediction
- Language: Jupyter Notebook
- Homepage:
- Size: 0 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 🧠 IV Delta Forecasting with XGBoost and LSTM
This notebook predicts the **daily change in implied volatility (ΔIV)** for SPY (S\&P 500 ETF) options using two distinct ML approaches:
* 🔺 **Quantile Regression with XGBoost**
* 🔁 **Sequential Forecasting with LSTM (Neural Network)**
## 📦 How It Works
### 1. **Data Collection**
* SPY (price, volume) and VIX (volatility index) are downloaded using `yfinance`.
* IV is approximated using 5-day rolling standard deviation of SPY returns.
* Target: **ΔIV = IV(t+1) - IV(t)**
### 2. **Feature Engineering**
* Market features: SPY returns, VIX, volume changes
* Option-style metadata: random DTE, call/put indicator
* Lagged IV/delta\_IV values
* Prophet-derived seasonal features (`trend`, `weekly`)
### 3. **Quantile XGBoost**
* Trains separate models for 10th, 50th, 90th percentiles
* Visualizes median forecast + confidence band (10–90%)
* Metrics: MAE, MSE, R², Directional Accuracy
### 4. **LSTM Model**
* Uses 60-day sequences of engineered features
* Predicts ΔIV using a simple 1-layer LSTM
* Evaluates performance and plots predictions + residuals
---
## 📈 Example Output
| Model | MAE | R² | Directional Accuracy |
| ------- | ------ | ------- | -------------------- |
| XGBoost | 0.0073 | -6.5655 | 42.4% |
| LSTM | 0.0029 | -4.4223 | 59.1% |
---
## 🛠 Requirements
Install dependencies using:
```bash
pip install yfinance prophet xgboost scikit-learn keras tensorflow
```
---
## ✅ Future Improvements
* Replace rolling IV with real implied volatility (from options chain)
* Use earnings calendar and macroeconomic events
* Test more advanced LSTM/Transformer architectures