Skip to content

SORADATA/Quantitative-AlphaEdge-AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

387 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“ˆ AlphaEdge: AI-Powered Multi-Market Portfolio Manager

Production-Ready Quantitative Trading System with Daily MLOps Pipeline

Machine-learning driven portfolio allocation for CAC40, with a reusable architecture that can be extended to additional markets.

Python 3.10+ Streamlit App MLflow Registry GitHub release (latest by date) License: MIT Code Style: Black

🌐 Live Dashboard β€’ πŸ“Š Performance β€’ πŸ—οΈ Architecture β€’ πŸš€ Quick Start β€’ πŸ› Issues


🎯 Overview

AlphaEdge is a quantitative portfolio management project that combines feature engineering, ensemble machine learning, portfolio optimization, and a Streamlit dashboard in a single codebase.

The current repository is organized around a CAC40 production setup, while keeping reusable modules for extension to other universes and market configurations.


🌟 Core Features

🧠 Machine Learning Engine

  • Ensemble modeling with XGBoost, LightGBM, Ridge, and Logistic Regression stacking
  • Market regime detection using K-Means on technical features
  • Walk-forward validation to evaluate temporal robustness before promotion

βš–οΈ Portfolio Construction

  • Mean-variance optimization with PyPortfolioOpt
  • Ledoit-Wolf covariance shrinkage for more stable risk estimates
  • Monthly rebalancing with transaction cost handling and fallback allocation logic

☁️ MLOps Workflow

  • MLflow-based registry / promotion workflow for model tracking
  • Local model fallback with ensemble_model.pkl and model_card.json
  • Automated workflows under .github/workflows/ for training, releases, and updates

πŸ“Š Visualization

  • Streamlit dashboard for performance monitoring and signal inspection
  • Dashboard screenshots already included in images/
  • Changelog and contribution files maintained at repository root

πŸ“Έ Dashboard Preview

Portfolio Performance AI Trading Signals
Dashboard Overview Trading Signals

πŸ“Š Performance Metrics

The dashboard section can display strategy return, benchmark comparison, drawdown, and signal information.

If you want this README to stay strictly accurate over time, update the numeric metrics directly from the latest dashboard or backtest output before each release.


πŸ—οΈ System Architecture

graph TB
    A[Market Data] --> B[ETL Pipeline]
    B --> C[Feature Engineering]
    C --> D[AlphaEdge Ensemble]
    D --> E[Backtest & Signal Engine]
    E --> F[Portfolio Optimization]
    F --> G[Artifacts / Model Cards / Signals]
    G --> H[Streamlit Dashboard]
    D -.-> I[MLflow Registry]
Loading

Main Components

  1. Extraction layer: market data loading and preprocessing
  2. Feature layer: momentum, volatility, risk-adjusted, and technical features
  3. Model layer: ensemble training, cross-validation, model loading, and promotion logic
  4. Pipeline layer: ETL, backtest, and daily execution utilities
  5. Presentation layer: Streamlit app for monitoring results

πŸš€ Quick Start

Prerequisites

  • Python 3.10+
  • Git
  • Recommended: virtual environment
  • Optional: HF_TOKEN for remote sync / registry integration

Installation

git clone https://github.com/SORADATA/CAC40-Quantitative-Analysis-Predictive-Asset-Allocation.git
cd CAC40-Quantitative-Analysis-Predictive-Asset-Allocation
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -r requirements.txt

Run the dashboard

streamlit run app.py

Run the daily pipeline

python src/pipeline/daily_run.py

Train the model

python src/models/train.py

πŸ“‚ Project Structure

.
β”œβ”€β”€ .github
β”‚   └── workflows
β”‚       β”œβ”€β”€ daily_update.yml
β”‚       β”œβ”€β”€ ml_pipeline.yml
β”‚       β”œβ”€β”€ pre-release.yml
β”‚       β”œβ”€β”€ python-app.yml
β”‚       └── release.yml
β”œβ”€β”€ CHANGELOG.md
β”œβ”€β”€ CONTRIBUTING.md
β”œβ”€β”€ README.md
β”œβ”€β”€ app.py
β”œβ”€β”€ config
β”‚   └── markets
β”‚       └── cac40.json
β”œβ”€β”€ const.py
β”œβ”€β”€ debug_run.txt
β”œβ”€β”€ dev.sh
β”œβ”€β”€ images
β”‚   β”œβ”€β”€ Dashboard.png
β”‚   └── Signal.png
β”œβ”€β”€ notebooks
β”‚   └── 01_EDA.ipynb
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ src
β”‚   β”œβ”€β”€ extract
β”‚   β”‚   β”œβ”€β”€ extractor.py
β”‚   β”‚   └── yfinance_downloader_test.py
β”‚   β”œβ”€β”€ features
β”‚   β”‚   └── alpha_features.py
β”‚   β”œβ”€β”€ models
β”‚   β”‚   β”œβ”€β”€ CAC40
β”‚   β”‚   β”‚   β”œβ”€β”€ ensemble_model.pkl
β”‚   β”‚   β”‚   └── model_card.json
β”‚   β”‚   β”œβ”€β”€ US_TECH
β”‚   β”‚   β”‚   β”œβ”€β”€ ensemble_model.pkl
β”‚   β”‚   β”‚   └── model_card.json
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ cv.py
β”‚   β”‚   β”œβ”€β”€ ensemble.py
β”‚   β”‚   β”œβ”€β”€ ensemble_model.pkl
β”‚   β”‚   β”œβ”€β”€ model_card.json
β”‚   β”‚   β”œβ”€β”€ model_loader.py
β”‚   β”‚   └── train.py
β”‚   β”œβ”€β”€ pipeline
β”‚   β”‚   β”œβ”€β”€ backtest.py
β”‚   β”‚   β”œβ”€β”€ daily_run.py
β”‚   β”‚   └── etl.py
β”‚   β”œβ”€β”€ transform
β”‚   β”‚   β”œβ”€β”€ processor.py
β”‚   β”‚   └── ticker_manager.py
β”‚   └── utils
β”‚       β”œβ”€β”€ config_loader.py
β”‚       β”œβ”€β”€ feature_utils.py
β”‚       β”œβ”€β”€ logger.py
β”‚       β”œβ”€β”€ market_utils.py
β”‚       β”œβ”€β”€ math_utils.py
β”‚       └── metrics.py
└── tests
    β”œβ”€β”€ get_composition.py
    β”œβ”€β”€ plot_results.py
    └── test_pipeline.py

πŸ”§ Customization

Add a new market

Create a new JSON file in config/markets/, for example:

{
  "market_name": "SP500",
  "tickers": ["AAPL", "MSFT", "GOOGL", "AMZN", "NVDA"],
  "benchmark_ticker": "^GSPC"
}

Then adapt the training and pipeline entry points so the new configuration is discovered and processed consistently.

Useful parameters

Parameter Role
SHARPE_THRESHOLD Promotion safety threshold
MAX_DD_THRESHOLD Max drawdown safety filter
PROBA_MIN Minimum prediction probability for selection
MAX_STOCKS_SELECT Maximum number of selected assets
MIN_STOCKS_OPTIM Minimum assets required for optimizer
TRANSACTION_COST Cost applied at rebalance
BACKTEST_YEARS Lookback window used in backtesting

πŸ“š Technical Notes

Feature Engineering

The project computes momentum, mean-reversion, volatility, technical, and risk-adjusted features inside src/features/alpha_features.py.

This layer is central because it transforms raw price history into the model inputs used for ranking and allocation.

Training Stack

The training logic lives in src/models/train.py, while the ensemble definition is implemented in src/models/ensemble.py.

Model loading and champion selection behavior are handled through src/models/model_loader.py plus local fallback artifacts.

Backtesting

The simulation and rebalance logic are implemented in src/pipeline/backtest.py.

This is where signal generation, allocation logic, and portfolio performance evaluation come together.


🀝 Contributing

Contributions are welcome through issues, discussions, and pull requests.

Before opening a PR, run formatting, linting, and tests locally where applicable.

black src/ --check
flake8 src/
pytest tests/

⚠️ Disclaimer

This repository is for educational and research purposes only.

It does not constitute financial advice, and past performance does not guarantee future results.


πŸ™ Acknowledgments

Developed as part of the Master 2 - Statistics Expertise for Finance & Economics program at UniversitΓ© de Lorraine.

Thanks to the open-source ecosystem around Streamlit, scikit-learn, XGBoost, LightGBM, PyPortfolioOpt, and MLflow.


Developed by SORADATA