Skip to content

s155003/stock-crash-ml

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Predicting U.S. Stock Market Crashes with Machine Learning

Code and data for the paper Machine Learning Models Accurately Predict Stock Market Crashes Using Macroeconomic Indicators (Aarav Pulsani, Texas A&M University).

Overview

This project uses supervised machine learning to predict U.S. stock market crashes at a six-month forward horizon. A crash is defined as a decline of 20% or more in the S&P 500 from its most recent peak, consistent with the conventional definition of a bear market. Monthly data from January 1990 through December 2023 (408 observations) were retrieved from FRED, the Bureau of Labor Statistics, the CBOE, and Robert Shiller's online dataset.

Features

Ten monthly macroeconomic indicators are used as model inputs, expanded to 30 features with 3-month and 12-month rolling averages:

Feature Type
S&P 500 Monthly Return Change
10Y-2Y Treasury Yield Spread Level
Unemployment Rate Change
CPI Inflation Rate Change
Federal Funds Rate Level
CBOE VIX Level
Shiller CAPE Ratio Level
Industrial Production Index Change
Consumer Confidence Index Level
M2 Money Supply Growth Change

Models

Five classifiers were implemented with scikit-learn and tuned via grid search with cross validation: logistic regression, decision tree, random forest, support vector machine, and multi-layer perceptron.

Results

Model Accuracy AUC
Random Forest 0.83 0.88
Multi-Layer Perceptron 0.81 0.86
Support Vector Machine 0.80 0.84
Decision Tree 0.75 0.78
Logistic Regression 0.71 0.74

Permutation feature importance identified the 10Y-2Y Treasury yield spread and the CBOE VIX as the most predictive features across all models, consistent with their established roles as recession and fear gauges.

Requirements

  • Python 3.9+
  • pandas, numpy, scikit-learn, matplotlib
pip install pandas numpy scikit-learn matplotlib

Usage

Clone the repository and run the analysis script to reproduce the dataset construction, model training, evaluation, and figures from the paper.

git clone https://github.com/s155003/stock-crash-ml.git
cd stock-crash-ml

Citation

If you use this code or data, please cite:

A. Pulsani, "Machine learning models accurately predict stock market crashes using macroeconomic indicators," 2026.

About

Machine learning pipeline for predicting U.S. stock market crashes using monthly macroeconomic indicators (1950–2023). Trains and compares five classifiers — logistic regression, decision tree, random forest, SVM, and MLP — on FRED and Yahoo Finance data. Includes feature engineering, grid search tuning, ROC analysis, and permutation importance.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors