Download option data using yfinance
Recent improvements were made to the Implied Volatility (IV) prediction model (train_prod_model.py and pricing.py):
- Asset Classes: Added support for specific tickers (
aapl,gold,sp500, etc.) and general asset classes (Stock, Index, Commodity). - Data Filtering: Excluded extreme IVs (outside 1% to 150%) and near-expiration options (DTE < 1.1).
- Target Transformation: Predicting
log(IV)to stabilize variance for better performance across different volatility regimes. - Feature Engineering: Added features like
inv_dte,vix_x_log_moneyness, VIX-basedatm_iv_proxy, and explicit buckets for Moneyness and DTE. - Training Strategy: Parallel loading of historical CSV data with 80/20 train/val split and Early Stopping.
- Model Tuning: Integrated Optuna for hyperparameter optimization across XGBoost, LightGBM, and CatBoost.
Data are stored in Parquet format, in the options_data and spread directories.
You can see some examples in DATA.md
Ensure you are in the virtual environment:
source venv/bin/activateTrain one or more models (XGBoost, LightGBM, CatBoost, YDF). The best model for general prediction is saved as iv_prod_xgb.json.
# Train XGBoost with Optuna tuning
python train_prod_model.py --models xgb --tune --tune-trials 50
# Train all supported models
python train_prod_model.py --models allPredicts IV, Price, and Greeks (Delta, Gamma, Vega, Theta, Rho) for a single strike.
Syntax:
python pricing.py <underlying> <strike> <days> <vix> [rate] [-t ticker] [-m model]Example:
python pricing.py 500 505 30 18.5 -t sp500 -m cbGenerates a beautiful console-rendered option chain (16 strikes above/below ATM) with IV skew and Greeks for both Calls and Puts.
Syntax:
python pricing-form.py <underlying> <days> <vix> [rate] [-t ticker] [-m model]Example:
python pricing-form.py 150.5 45 22.1 -t aapl -m xgbNote: Supported tickers for the -t flag include: gold, silver, longterm, aapl, amzn, goog, sp500, nq100, dowjones. Use stock, index, or commodity for general asset class defaults.
Supported models for the -m flag include: cb (CatBoost, default), xgb (XGBoost), lgb (LightGBM), ydf (YDF).