Production-Ready Quantitative Trading System with Daily MLOps Pipeline
Combining Unsupervised Learning, XGBoost & Modern Portfolio Theory for Automated Asset Allocation
π Live Dashboard β’ π View Results β’ π Quick Start β’ π Report Issue
Traditional portfolio management relies on static allocations and reactive rebalancing. AlphaEdge flips this paradigm by implementing a fully automated, AI-driven investment strategy that:
- π Rebalances daily based on market regime detection and predictive signals
- π€ Requires zero manual intervention through GitHub Actions automation
- π Adapts to market conditions using unsupervised learning for regime classification
- β‘ Responds to signals in real-time with optimized portfolio weights
- π Built on academic rigor from quantitative finance research
Perfect for: Quantitative researchers, algo traders, data scientists, and finance students looking to deploy production-grade ML strategies.
- Market Regime Detection: K-Means clustering identifies bullish, bearish, and neutral market states
- Directional Forecasting: XGBoost predicts next-day returns with probability scores
- Ensemble Strategy: Combines both models for robust signal generation
- Markowitz Mean-Variance Framework with Ledoit-Wolf covariance shrinkage
- Dynamic risk constraints adjusted by market volatility
- Transaction cost modeling to minimize portfolio turnover
- Automated daily ETL via GitHub Actions (no servers needed)
- Version-controlled models with reproducible training pipeline
- Monitoring & alerting through Streamlit dashboard
- Scalable architecture ready for multi-asset expansion
- Real-time performance tracking vs CAC40 benchmark
- Signal visualization with confidence intervals
- Drawdown analysis and risk metrics
- Portfolio composition timeline
| Portfolio Performance | AI Trading Signals |
|---|---|
![]() |
![]() |
Live tracking of cumulative returns, Sharpe ratio, and maximum drawdown (left). Daily probabilistic forecasts with market regime indicators (right).
Data updated as of: 2026-02-05
| Metric | AlphaEdge Strategy π€ | CAC40 Benchmark π«π· |
|---|---|---|
| Total Return | +121.9% π | +87.9% |
| Alpha (vs Bench) | +34.0% | N/A |
| YTD Performance | +9.5% | TBD |
| Sharpe Ratio | 0.63 | N/A |
| Max Drawdown | -32.0% | TBD |
Note: The strategy has shown significant outperformance in the recent period (2024-2026), successfully identifying market regime shifts.
Metrics updated daily. View real-time performance on the live dashboard.
The entire pipeline runs autonomously with zero maintenance required.
graph TB
A[π Yahoo Finance API] -->|Daily at Market Close| B[Data Ingestion]
B --> C[Feature Engineering]
C --> D{AI Model Ensemble}
D -->|Regime Detection| E[K-Means Clustering]
D -->|Return Prediction| F[XGBoost Classifier]
E & F --> G[Signal Aggregation]
G --> H[Portfolio Optimization]
H -->|Markowitz + Constraints| I[Weight Allocation]
I --> J[π Export Results]
J --> K[π Streamlit Dashboard]
J --> L[π Backtest Analysis]
style A fill:#e1f5ff
style D fill:#fff4e1
style H fill:#ffe1f5
style K fill:#e1ffe1
- Data Layer: Real-time market data from Yahoo Finance API
- Feature Store: Technical indicators (RSI, MACD, Bollinger Bands) + macro factors
- ML Models: Pre-trained and versioned in
/src/models/ - Optimization Engine: PyPortfolioOpt with custom risk models
- Deployment: GitHub Actions + Streamlit Cloud (serverless)
- Python 3.10 or higher
- Git installed
- (Optional) Virtual environment tool
# Clone the repository
git clone https://github.com/SORADATA/CAC40-Quantitative-Analysis-Predictive-Asset-Allocation.git
cd CAC40-Quantitative-Analysis-Predictive-Asset-Allocation
# Create virtual environment (recommended)
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txtOption 1: Launch Dashboard
streamlit run app.pyOpens interactive dashboard at http://localhost:8501
Option 2: Run Pipeline Manually
python daily_run.pyExecutes full ETL, prediction, and optimization cycle
Option 3: Explore Notebooks
jupyter notebook notebooks/Access research notebooks for model training and backtesting
CAC40-Quantitative-Analysis-Predictive-Asset-Allocation/
βββ .github/
β βββ workflows/
β βββ daily_pipeline.yml # Automated daily execution
βββ data/
β βββ raw/ # Historical price data
β βββ processed/ # Feature-engineered datasets
β βββ results/ # Portfolio weights & signals
βββ images/ # Screenshots & visualizations
βββ notebooks/
β βββ 01_EDA.ipynb # Exploratory data analysis
β βββ 02_Model_Training.ipynb # ML model development
β βββ 03_Backtesting.ipynb # Strategy validation
βββ src/
β βββ models/
β β βββ xgboost_model.pkl # Trained predictor
β β βββ kmeans_model.pkl # Regime classifier
β βββ utils/
β β βββ data_loader.py # ETL functions
β β βββ feature_engineering.py # Indicator calculations
β β βββ optimization.py # Portfolio allocation
β β βββ evaluation.py # Performance metrics
β βββ config.py # Centralized configuration
βββ app.py # Streamlit dashboard
βββ daily_run.py # Main pipeline orchestrator
βββ requirements.txt # Python dependencies
βββ LICENSE # MIT License
βββ README.md # You are here!
Want to apply this strategy to S&P 500, FTSE 100, or cryptocurrencies?
-
Fork this repository (click the Fork button above)
-
Modify the ticker list in
src/config.py:
# Example: Switch to S&P 500
TICKERS = ['AAPL', 'MSFT', 'GOOGL', 'AMZN', 'NVDA', ...]
BENCHMARK = '^GSPC' # S&P 500 index- Retrain models (optional but recommended):
python notebooks/02_Model_Training.ipynb- Push changes and the automated pipeline handles the rest!
Key configuration options in src/config.py:
| Parameter | Description | Default |
|---|---|---|
LOOKBACK_PERIOD |
Historical window for features | 252 days |
N_CLUSTERS |
Market regimes for K-Means | 3 |
RISK_AVERSION |
Portfolio risk tolerance | 2.5 |
MAX_WEIGHT |
Position size limit per asset | 0.15 |
REBALANCE_THRESHOLD |
Trigger for portfolio adjustment | 5% |
The model uses 50+ features across multiple categories:
- Price-based: Returns (1d, 5d, 20d), log-returns, price ratios
- Technical Indicators: RSI, MACD, Bollinger Bands, ATR, Stochastic Oscillator
- Volume Metrics: OBV, Volume MA ratios, VWAP
- Volatility Measures: Historical vol, Parkinson estimator, Garman-Klass
- Market Microstructure: Bid-ask spread proxies, Amihud illiquidity
XGBoost Classifier:
- Binary classification (up/down next day)
- Custom weighted loss function (asymmetric)
- 5-fold time-series cross-validation
- Hyperparameter tuning via Optuna
K-Means Clustering:
- Applied to 10 macro features (volatility, momentum, correlation)
- Elbow method + Silhouette score for optimal K
- Regime labels: Bull (0), Neutral (1), Bear (2)
Implements Markowitz Mean-Variance Optimization with:
- Expected returns via exponentially weighted moving average (EWMA)
- Covariance matrix via Ledoit-Wolf shrinkage (addresses estimation error)
- Constraints: Long-only, box constraints, sector limits
- Objective: Maximize Sharpe ratio with L2 regularization
Contributions are welcome! Here's how you can help:
- Report bugs via GitHub Issues
- Suggest features in the Discussions tab
- Submit pull requests following the code style guidelines
# Install development dependencies
pip install -r requirements-dev.txt
# Run linting
black src/ --check
flake8 src/
# Run tests
pytest tests/This project builds upon:
- Markowitz, H. (1952). "Portfolio Selection". Journal of Finance
- Friedman, J. et al. (2001). "Greedy Function Approximation: A Gradient Boosting Machine"
- Ledoit, O. & Wolf, M. (2004). "Honey, I Shrunk the Sample Covariance Matrix"
- Bailey, D. et al. (2017). "Stock Portfolio Design and Backtest Overfitting". Journal of Investment Management
This project is for educational and research purposes only.
- β Not financial advice or investment recommendations
- β No guarantee of profitability or performance
- β Past results do not predict future outcomes
β οΈ Algorithmic trading involves substantial risk of capital loss
Always consult with a licensed financial advisor before making investment decisions.
This project is licensed under the MIT License - see the LICENSE file for details.
You are free to use, modify, and distribute this code with attribution.
Developed as part of the Master 2 - Statistics Expertise for Finance & Economics program at UniversitΓ© de Lorraine.
Special thanks to:
- Professor [Name] for guidance on quantitative methods
- The open-source community for libraries (Streamlit, scikit-learn, PyPortfolioOpt)
- CAC40 companies for providing publicly available data
β Star this repo to show support!
π Fork it to build your own strategy!
π’ Share it with fellow quants and developers!
Developed by SORADATA

