Market Regime Fingerprinter
A Unified Machine Learning System for Detecting and Predicting Financial Market Regimes.
π Overview
Understanding whether the market is in a predictable trend, a volatile chop, or a liquidity crisis is crucial for portfolio management. This project uses Unsupervised Learning (K-Means) to discover hidden market states ("Regimes") and Supervised Learning (XGBoost) to predict these states in real-time.
π Architecture
- Data Ingestion: Fetches daily OHLCV data via
yfinance. - Feature Engineering: Calculates Rolling Volatility, RSI, MACD, ATR, Volume Z-Scores, and Price Acceleration.
- Regime Discovery:
- Uses K-Means Clustering on stability/volatility features.
- Automatically segments history into distinct regimes.
- Dynamic Labeling: The app intelligently names regimes (e.g., "Steady Bull", "Crash") based on their statistical properties (Returns vs Volatility).
- Classification:
- Trains an XGBoost Classifier to map daily features to the discovered regime.
- Optimized for deployability and interpretability.
- Inference UI:
- A Gradio web app for visualizing regimes and "Regime Fingerprints" (SHAP explanations).
- Includes a Novice Mode with natural language explanations and a glossary.
π Installation
pip install -r requirements.txt
π Usage
1. Data & Training Pipeline
Run the following scripts in order:
# 1. Download Data & Generate Features
python src/data_loader.py
# 2. Discover Regimes (Clustering)
python src/regime_discovery.py
# 3. Train Classifier
python src/train_classifier.py
2. Run the App
Launch the interactive dashboard:
python app.py
β οΈ Disclaimer
This is a research project for educational purposes only.
- This model classifies historical behavioral patterns, not future prices.
- Market regimes do not guarantee future behavior.
- NOT FINANCIAL ADVICE. Do not trade based on these signals.
Inference Providers NEW
This model isn't deployed by any Inference Provider. π Ask for provider support