π«π· Ce README est aussi disponible en franΓ§ais.
This project presents the portfolio optimization module developed for the SiraEdge platform β an innovative solution designed to democratize access to professional-grade asset management tools.
SiraEdge was born from a simple yet ambitious vision: to democratize access to professional portfolio management tools.
Our mission is to make finance accessible to everyone by combining mathematical rigor with an intuitive user experience.
- Accessibility: Democratizing finance through pedagogy
- Innovation: Leveraging the latest advances in quantitative finance
- Excellence: Robust code, optimal performance, and reliability
This module implements and analyzes 7 portfolio optimization models:
- Foundation of modern portfolio theory
- Maximization of the Sharpe ratio
- Balancing risk and return
- Equalizing risk contributions across assets
- Robustness to return uncertainty
- Natural diversification
- Random exploration of the solution space
- Visualization of the efficient frontier
- Validation of candidate solutions
- Combining market equilibrium with investor views
- Adjusted equilibrium portfolio
- Institutional-grade approach
- Forecasting returns using AI
- Analysis of technical patterns (RSI, momentum, volatility)
- Objective quantitative signals
- Combination of Risk Parity + ML signals
- Stable foundation + smart opportunism
- Core-satellite approach
- Tailor-made objectives (Sharpe + Stability + MDD + Turnover)
- Adapted to investor preferences
- Multi-objective optimization
SiraEdge_Optimisation/
βββ src/ # Python source code
β βββ data_utils.py # Data utilities and indicators
β βββ markowitz.py # Markowitz optimization
β βββ risk_parity.py # Risk parity optimization
β βββ monte_carlo.py # Monte Carlo simulation
β βββ black_litterman.py # Black-Litterman model
β βββ ml_predictor.py # ML predictor
β βββ hybrid_model.py # Hybrid model
β βββ custom_metrics_opt.py # Custom metrics optimization
β βββ metrics_utils.py # Financial metrics calculations
β βββ walkforward_backtest.py # Walk-forward backtesting
β βββ hyperparams.py # Centralized hyperparameters
βββ figures/ # Charts and visualizations
β βββ markowitz_frontier.png
β βββ risk_parity_weights.png
β βββ monte_carlo_cloud.png
β βββ black_litterman_weights.png
β βββ ml_coefficients.png
β βββ hybrid_weights.png
β βββ custom_opt_weights.png
βββ rapport/ # LaTeX report sources
β βββ rapport_siraedge_en.tex # English report
β βββ rapport_siraedge_fr.tex # French report
β βββ portfolio_summary_included.tex
β βββ walkforward_results_simulated.tex
βββ README.md # This file
βββ requirements.txt # Python dependencies
βββ make_report.sh # Automated generation script
- Python 3.8+
- pip or conda
- Git (for cloning)
- Clone the repository
git clone https://github.com/IsmailMoudden/siraedge-module.git
cd siraedge-module
- Install dependencies
pip install -r requirements.txt
- Verify installation
python -c "import pandas, numpy, matplotlib, yfinance; print('Installation successful!')"
# Generate all figures and visualizations
python src/data_utils.py
python src/markowitz.py
python src/risk_parity.py
python src/monte_carlo.py
python src/black_litterman.py
python src/ml_predictor.py
python src/hybrid_model.py
python src/custom_metrics_opt.py
python src/walkforward_backtest.py
# Use automatic script
chmod +x make_report.sh
./make_report.sh
# Or manual compilation
cd rapport
# For English report
tectonic rapport_siraedge_en.tex
# For French report
tectonic rapport_siraedge_fr.tex
# Example usage of the Risk Parity module
import numpy as np
from src.risk_parity import risk_parity_weights
from src.data_utils import download_prices
# Download asset prices
prices = download_prices(["SPY", "QQQ", "GLD", "DBA"], "2020-01-01", "2023-12-31", mode="auto")
rets = np.log(prices / prices.shift(1)).dropna()
cov = (rets.cov().values) * 252
# Calculate Risk Parity weights
weights = risk_parity_weights(cov)
print("Optimal weights:", weights)
- ETFs : SPY, QQQ, IWM, EFA
- Commodities : GLD, SLV, USO, DBA
- Window : 2020-2023
- FrΓ©quency : Daily data
- Rebalancing : Monthly (walk-forward)
- RSI (Relative Strength Index)
- Momentum (20-day returns)
- Rolling volatility (20-day window)
- Dynamic correlations
The module includes a robust walk-forward analysis:
- Rolling window: 252 days (1 trading year)
- Rebalancing: Monthly
- Transaction costs: 5 bps
- Metrics: Sharpe, Calmar, Sortino, Stability, Turnover
- Sharpe Ratio β risk-adjusted return
- Sortino Ratio β downside risk-adjusted return
- Calmar Ratio β return vs. max drawdown
- Volatility β annualized risk
- Weight stability β allocation consistency
- Turnover β trading activity
- Effective diversification β equivalent number of assets
- Average correlation β portfolio cohesion
- Markowitz: Traditional mean-variance optimization
- Risk Parity: Equal risk contribution approach
- Black-Litterman: Institutional-grade equilibrium model
- ML Hybrid: AI-enhanced optimization
- Custom Metrics: Multi-objective solutions
- Period: 2020-2023 (3+ years)
- Assets: 8+ ETFs and commodities
- Rebalancing: Monthly walk-forward
- Transaction Costs: 5 basis points
- Risk Management: Dynamic correlation analysis
This project is designed to be educational and accessible:
- Detailed explanations of each concept
- Concrete examples with numbers
- Simple analogies for complex ideas
- Commented and documented code
- End-to-end workflow from start to finish
- 7 state-of-the-art models for portfolio construction
- Risk management with multiple approaches
- Machine learning integration for return forecasting
- Custom metrics for specialized objectives
- Walk-forward analysis with rolling windows
- Transaction costs simulation (5 bps)
- Comprehensive metrics (Sharpe, Sortino, Calmar, etc.)
- Performance attribution and analysis
- Automatic data download via yfinance
- Fallback mechanisms for data failures
- Professional charts and visualizations
- Export capabilities for reports
- Estimation windows (126, 252, 504 days)
- ML signal intensity (alpha)
- Confidence in Black-Litterman views (tau)
- Weights for custom metrics
- Asset weight limits
- Sector/asset class constraints
- Turnover penalties
- Leverage constraints
The full reports are available in both French and English:
- English Report:
rapport/pdf/rapport_siraedge_en.pdf
- French Report:
rapport/pdf/rapport_siraedge_fr.pdf
Both reports include:
- Detailed theoretical explanations
- Mathematical formulations
- Comparative analyses
- Results and interpretations
- Practical limitations and considerations
- Complete implementations of the models
- Lightweight comments and docstrings for key functions
- Data fallback: automatic switch to synthetic series if download fails
This module integrates directly into the SiraEdge platform to allow users to:
- Test different optimization models
- Compare performance in real time
- Understand riskβreturn trade-offs
- Learn by doing, with immediate feedback (educational focus)
- Portfolio theory studies and research
- Algorithm comparison and validation
- Risk management research
- Machine learning in finance applications
- Quantitative finance learning
- Portfolio management skills development
- Risk analysis training
- Financial modeling practice
- Backtesting new strategies
- Risk assessment tools
- Performance analysis frameworks
- Educational platforms for teams
Scope: this module is intended for educational and comparative purposes only.
It does not constitute investment advice or performance guarantees.
This project is licensed under the MIT License. See the LICENSE
file for details.
- Author: Ismail Moudden
- GitHub Repository: https://github.com/IsmailMoudden/Portfolio-Optimization-Module-SiraEdge
- Issues & Support: https://github.com/IsmailMoudden/siraedge-module/issues
- Documentation: Contributing Guide | Changelog
We welcome contributions to improve the Portfolio Optimization Module! Please see our Contributing Guide for details on:
- Code style and standards
- Testing requirements
- Pull request process
- Issue reporting guidelines
- Current Version: 1.0.0
- Python Support: 3.8+
- License: MIT
- Status: Active Development
- Last Updated: January 2025
SiraEdge β Making finance accessible, transparent, and innovative for everyone. π