SPY Next-Day Direction Prediction
Predict whether the SPDR S&P 500 ETF (SPY) closes higher the next trading day using classic ML models and lightweight technical features.
Python
pandas
scikit-learn
matplotlib
Time-series split
Overview
Classic baselines • clean evaluation • educational
What this project does
The script builds a simple pipeline that downloads SPY OHLCV data, engineers a small feature set (returns, SMAs, rolling volatility), then trains Logistic Regression, KNN, and a Decision Tree — and compares them against a baseline (“always up”).
Models + approach
- Logistic Regression (with scaling)
- K-Nearest Neighbors (with scaling)
- Decision Tree
- Baseline: always predict “up”
- Split: chronological train/val/test (70% / 10% / 20%)
How to run
pip install kagglehub pandas numpy scikit-learn matplotlib
python main.py
Note: This is an educational project — not financial advice.
Outputs
- Distribution plot of daily log returns
- F1 score comparison across models
- “Helper output” prediction for the most recent day