Skip to content

CarloFeliceCardon/portfolio-optimization

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Portfolio Optimization with Modern Portfolio Theory

Overview

This project implements portfolio optimization techniques based on Modern Portfolio Theory (MPT) using historical market data downloaded from Yahoo Finance.

Firstly, a two-asset analytical example is developed, then, the optimization is conducted on portfolios of five-assets.

The analysis focuses on constructing efficient portfolios, evaluating their risk-return characteristics, and comparing different investment strategies through several financial performance metrics.


Key Results

  • Optimized multi-asset portfolios using constrained mean-variance optimization
  • Compared Minimum Variance, Maximum Sharpe and Return-constrained portfolios
  • Evaluated portfolios through Sharpe, Treynor, Alpha, Beta and Maximum Drawdown
  • Tested portfolio robustenss across bull and bear market regimes
  • Visualized efficient frontier, allocation, drawdowns and correlation dynamics

Asset Selection

The selected ETFs represent the main strategic asset classes of a diversified global portfolio:

  • US Equities
  • Global Equities
  • Government Bonds
  • Gold
  • Risk-free Asset

Features

  • Historical market data download using yfinance
  • Daily and annualized return calculation
  • Covariance matrix estimation
  • Efficient Frontier construction
  • Maximum Sharpe Ratio Portfolio optimization
  • Minimum Variance Portfolio optimization
  • Portfolio allocation under weight constraints
  • Monte Carlo portfolio simulation
  • Capital Market Line (CML)
  • Performance evaluation through:
    • Expected Return
    • Volatility
    • Sharpe Ratio
    • Treynor Ratio
    • Alpha
    • Beta
    • Maximum Drawdown
  • Bull and Bear market sub-period analysis
  • Graphical visualization of portfolio performance

Alpha, Beta and Treynor Ratio are computed relative to the MSCI ACWI benchmark, while BIL is used as a proxy for the risk-free rate.


Sample Output

Efficient Frontier

Efficient Frontier

Correlation in Bear and Bull Markets

Correlation

Historical Performance

Performance

Underwater Chart

Underwater Chart

Technologies

  • Python 3
  • NumPy
  • Pandas
  • SciPy
  • Matplotlib
  • seaborn
  • yfinance

Project Structure

portfolio_analysis.py
README.md
requirements.txt

Installation

Clone the repository

git clone https://github.com/yourusername/portfolio-analysis.git

Install the required libraries

pip install -r requirements.txt

Running the Project

Execute

python portfolio_analysis.py

The script automatically:

  1. Downloads historical market data
  2. Computes daily and annual statistics
  3. Generates optimized portfolios
  4. Builds the Efficient Frontier
  5. Evaluates portfolio performance
  6. Produces graphs and summary statistics

Performance Metrics

The project computes several financial indicators, including:

  • Expected Annual Return
  • Annual Volatility
  • Sharpe Ratio
  • Treynor Ratio
  • Jensen's Alpha
  • Beta
  • Maximum Drawdown

Methodology

Portfolio optimization is performed using constrained numerical optimization (scipy.optimize.minimize).

The objective functions include:

  • Maximum Sharpe Ratio
  • Minimum Portfolio Variance

Subject to:

  • Portfolio weights sum to one
  • Minimum and maximum allocation constraints

Data Source

Historical price data are retrieved from Yahoo Finance using the yfinance package.


Educational Purpose

This project was developed as part of an academic study on portfolio management and quantitative finance. It is intended for educational purposes and should not be interpreted as investment advice.

About

Portfolio optimization using Modern Portfolio Theory with Efficient Frontier, Sharpe Ratio optimization, and CAPM performance analysis.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages