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.
- 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
The selected ETFs represent the main strategic asset classes of a diversified global portfolio:
- US Equities
- Global Equities
- Government Bonds
- Gold
- Risk-free Asset
- 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.
- Python 3
- NumPy
- Pandas
- SciPy
- Matplotlib
- seaborn
- yfinance
portfolio_analysis.py
README.md
requirements.txt
Clone the repository
git clone https://github.com/yourusername/portfolio-analysis.gitInstall the required libraries
pip install -r requirements.txtExecute
python portfolio_analysis.pyThe script automatically:
- Downloads historical market data
- Computes daily and annual statistics
- Generates optimized portfolios
- Builds the Efficient Frontier
- Evaluates portfolio performance
- Produces graphs and summary statistics
The project computes several financial indicators, including:
- Expected Annual Return
- Annual Volatility
- Sharpe Ratio
- Treynor Ratio
- Jensen's Alpha
- Beta
- Maximum Drawdown
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
Historical price data are retrieved from Yahoo Finance using the yfinance package.
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.



