A professional-grade Python implementation of Multi-Objective Portfolio Optimization. This project combines advanced time-series forecasting (Spectral Mixture Gaussian Processes) with state-of-the-art evolutionary algorithms (MOEA/D) to find optimal asset allocations.
This repository provides a modular framework for:
- Price Prediction: Using Gaussian Processes with Spectral Mixture (SM) kernels to capture complex periodicity and trends in financial data.
- Portfolio Modeling: Defining multi-objective problems including Expected Return, Risk (Variance), and Diversification (HHI Index).
- Pareto Front Discovery: Solving the optimization problem using classical (Weighted Sum, Epsilon-Constrained) and evolutionary (MOEA/D) approaches.
- Weighted Sum: Aggregates objectives into a single scalar value.
- Epsilon-Constrained (ECM): Maximizes return while keeping other objectives within strict bounds. Used as the ground-truth reference for quality metrics.
- Standard MOEA/D: Decomposes the problem into subproblems with fixed weight vectors.
- MOEA/D-DRA (Dynamic Resource Allocation): Optimizes computational efficiency by focusing on subproblems that show the most improvement.
- MOEA/D-AWA (Adaptive Weight Adjustment): Dynamically repositions weight vectors during search to ensure a uniform distribution of solutions across the Pareto front.
├── .github/workflows/ # CI/CD Pipeline (Linting & Formatting)
├── data/ # Historical asset price data (CSV)
├── scripts/ # Experiment entry points
│ ├── experiment_standard.py # Classical optimization comparison
│ ├── experiment_moead.py # Basic MOEA/D vs ECM
│ ├── experiment_dra.py # Performance & efficiency testing
│ └── experiment_awa.py # Diversity & distribution testing
├── src/
│ ├── portfolio/ # Core optimization logic
│ │ ├── metrics.py # Quality metrics (IGD, Spacing, Spread)
│ │ ├── moead_base.py # Common evolutionary logic
│ │ └── ...
│ ├── predictors.py # GP-SM Regression models
│ └── visualization.py # Advanced plotting and 3D animations
└── requirements.txt # Dependency list
-
Clone the repository:
git clone https://github.com/MichalRedm/portfolio-optimization.git cd portfolio-optimization -
Create and activate a virtual environment:
python -m venv .venv # Windows .venv\Scripts\activate # Linux/macOS source .venv/bin/activate
-
Install dependencies:
pip install -r requirements.txt
The project includes several built-in experiments to evaluate algorithm performance.
python scripts/experiment_standard.pypython scripts/experiment_moead.pypython scripts/experiment_dra.pypython scripts/experiment_awa.pyWe evaluate the quality of the found Pareto fronts using:
- IGD (Inverted Generational Distance): Measures how close the found solutions are to the true Pareto front.
- Spacing: Measures how evenly the solutions are distributed.
- Spread: Measures how well the solutions cover the entire objective space.
The framework generates high-quality visualizations, including:
- 2D Comparisons: Scatter plots showing the Pareto front against reference models.
- 3D Animations: Interactive rotation of 3D fronts (Return vs Risk vs Diversification) saved as smooth GIFs (25 FPS).
- Efficiency Plots: Performance over time (IGD vs. Function Evaluations).
This project is licensed under the MIT License - see the LICENSE file for details.