← Back to projects

Stock Volume Forecast: S&P 100 Daily Volume Prediction

Python XGBoost PyTorch Time Series Plotly Dash

View Live Dashboard

The Problem

Trading volume drives liquidity, execution quality, and volatility. If you're placing a large order, you need to know whether tomorrow will have 30 million shares traded or 80 million. The difference determines whether your order moves the market or not. Volume forecasting is a real problem in quantitative finance, and unlike price prediction, it's actually solvable.

What I Built

A fully automated ML pipeline that predicts 30-day trading volume for 102 stocks in the S&P 100. Trains 4 models per ticker, picks the best one, and serves predictions through an interactive dashboard. The whole thing retrains daily after market close with zero manual intervention.

Why Volume and Not Price?

Daily stock prices are essentially a random walk and no model consistently outperforms simple baselines. Volume is different: it has strong weekly patterns (Mondays higher, Fridays lighter), mean-reverts after spikes, and correlates with observable signals like price moves and calendar events. XGBoost hits 3-7% MAPE on most tickers. You'd never get that on price.

Feature Engineering

31 features per ticker, all engineered from raw OHLCV data:

GroupFeaturesRationale
Volume trend5/10/20/50-day moving averagesSmooths noise, shows if volume is trending up or down
AutoregressiveLag 1, 2, 3, 5, 10 daysYesterday's volume is the single best predictor of today's
NormalizedVolume / 20-day MA, percent changeLets the model compare across different volume scales
Price signalsReturn, abs return, range, gap, volatilityBig price moves cause volume spikes
CalendarDay-of-week (one-hot), month, month-endMondays spike, month-end sees rebalancing flows

Model Comparison

All models trained on 85% of data (~630 days), evaluated on the final 15% (~112 days). Strictly chronological split with no future data leaking into training.

ModelAvg MAPEWinsNotes
XGBoost5.49%91/102Handles tabular features and nonlinear interactions
Linear Regression8.07%11/102Surprisingly strong. Good features beat fancy models
ARIMA28.90%0Only sees volume history, can't use price/calendar features
LSTM30.61%0Not enough data. Deep learning needs thousands of samples, not hundreds

The Takeaway

XGBoost with good feature engineering beats a neural network with the same features. This isn't surprising. At 700 rows of data, gradient boosting has enough signal and LSTM doesn't. The linear model winning 11 tickers proves the features themselves carry most of the predictive power.

Pipeline

Yahoo Finance → data pull → feature engineering (31 features)
    → train 4 models × 102 tickers → evaluate → pick best per ticker
    → generate 30-day predictions → serve via Dash dashboard

Runs daily via cron at 5:30pm ET. Dashboard reads pre-computed JSON files for instant page loads.

What I'd Improve