Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Portfolio Optimization Framework

A modular Python framework for comparing covariance matrix estimators and portfolio allocation algorithms using rolling out-of-sample backtesting.

The project is designed to evaluate the impact of covariance estimation on portfolio construction in a high-dimensional setting, with a focus on Global Minimum Variance (GMV) and Hierarchical Risk Parity (HRP) portfolios.

Features

Covariance estimators

  • Sample Covariance
  • Ledoit–Wolf Linear Shrinkage
  • Quadratic-Inverse Shrinkage (QIS)

Portfolio allocators

  • Equal Weight
  • Global Minimum Variance (GMV)
  • Hierarchical Risk Parity (HRP)

Performance evaluation

  • Rolling walk-forward backtesting
  • Annualized return
  • Annualized volatility
  • Sharpe ratio
  • Maximum drawdown

Technologies

  • Python
  • NumPy
  • Pandas
  • SciPy
  • scikit-learn
  • CVXPY
  • yfinance

Project architecture

flowchart TD
    A([Returns])
    A --> B["Covariance Estimator:
        • Sample
        • Linear Shrinkage
        • Nonlinear Shrinkage"]
    B --> C([Covariance Matrix])
    C --> D["Portfolio Allocator:
        • Equal Weight
        • Global Minimum Variance
        • Hierarchical Risk Parity"]
    D --> E([Rolling Backtest])
    E --> F([Performance Metrics])
Loading

Installation

Clone the repository:

git clone https://github.com/<your-username>/portfolio-optimization.git
cd portfolio-optimization

Install the required packages:

pip install -r requirements.txt

Usage

Run the demonstration notebook:

jupyter notebook notebooks/demo.ipynb

Alternatively, open the repository in VS Code and run

notebooks/demo.ipynb

The notebook is self-contained and can be run from top to bottom.

Repository structure

src/
├── allocators/
├── backtesting/
├── covariance/
├── metrics/
└── utils/

notebooks/
tests/
data/

Benchmark

The framework supports systematic benchmarking of different combinations of

  • covariance estimators,
  • portfolio allocation methods,
  • hierarchical clustering linkage methods,

using rolling out-of-sample evaluation.

Example output

The benchmark produces a comparison table containing

Portfolio Annualized Return Annualized Volatility Sharpe Ratio Maximum Drawdown
Sample | GMV ... ... ... ...
Linear Shrinkage | HRP (average) ... ... ... ...

as well as cumulative wealth plots for each portfolio strategy.

About

A modular Python framework for covariance estimation, portfolio optimization, and rolling out-of-sample backtesting.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages