This project explores the relationship between corporate earnings reports and short-horizon stock price volatility. Using historical market data and earnings schedules, the goal is to evaluate whether volatility around earnings events can be anticipated using machine learning models.
The accompanying notebook contains exploratory analysis and multiple modeling approaches; this README summarizes the final, defensible results.
- Universe: 50 S&P 500 equities
- Time Range: 2020–2025
- Target: Short-term realized / rolling volatility
- Focus: Feature engineering, model comparison, and time-series prediction
Key questions addressed:
- Can future volatility be predicted using historical price, volume, and event-based features?
- Do earnings reports meaningfully contribute to volatility dynamics?
- Yahoo Finance (yfinance):
- Daily open, high, low, close, and volume
- Alpha Vantage API:
- Earnings report dates
- Reported and estimated EPS
- Earnings surprise metrics
Stock tickers were scraped from Wikipedia’s S&P 500 list and standardized for API compatibility.
Engineered features include:
- Logarithmic returns
- Rolling volatility (derived from log returns)
- Relative Strength Index (RSI) and RSI classification
- Days to earnings (countdown to next earnings report)
- Lagged volatility features
- Volume-based rolling statistics
- Earnings-based features (e.g., last reported EPS)
These features were synchronized on a daily time scale for each stock.
The following models were implemented and compared:
- Linear Regression
- Used as a baseline to understand volatility persistence
- XGBoost
- Used primarily for feature importance and non-linear relationships
- LSTM (Long Short-Term Memory Neural Network)
- Used for sequential time-series prediction and final evaluation
Validation strategies included held-out evaluation for classical models and sequential (time-aware) holdout for the LSTM.
| Model | Purpose | Performance |
|---|---|---|
| Linear Regression | Baseline / exploratory | Used for comparison |
| XGBoost | Feature importance & baseline prediction | Lower predictive performance |
| LSTM | Primary predictive model | R² ≈ 0.79 on unseen time-series data |
The LSTM demonstrated the strongest generalization performance when evaluated on future, unseen time periods, highlighting the importance of sequence-aware modeling for volatility prediction.
- Stock-Volatility.ipynb contains the full data pipeline, feature engineering, exploratory analysis, and model implementations.
- Some sections reflect exploratory work conducted during development.
- Built the end-to-end data pipeline and feature engineering framework for price, volatility, and earnings-based signals.
- Implemented and evaluated linear, tree-based, and neural network models for volatility prediction.
- Conducted analysis, visualization, and interpretation of results, and contributed to the final project write-up.
Dependencies: yfinance pandas numpy matplotlib seaborn scipy scikit-learn xgboost tensorflow tqdm lxml