This project applies Modern Portfolio Theory (MPT) to analyze the trade-off between risk and return across a portfolio of assets.
Using Monte Carlo simulation and numerical optimization, it identifies the maximum Sharpe ratio and minimum variance portfolios, visualizing the efficient frontier that represents optimal investment strategies.
- Goal: Model and optimize investment portfolios using historical stock data.
- Approach:
- Simulate thousands of random portfolios to explore possible risk–return combinations.
- Apply optimization techniques (
scipy.optimize) to find portfolios with the best risk-adjusted return and the lowest volatility.
- Core Concepts:
- Monte Carlo Simulation
- Covariance-based Risk Modeling
- Efficient Frontier Visualization
- Sharpe Ratio Maximization
- Modern Portfolio Theory (MPT)
| Category | Tools |
|---|---|
| Programming | Python |
| Libraries | NumPy, Pandas, Matplotlib, SciPy, yFinance |
| Optimization | scipy.optimize.minimize (SLSQP) |
| Data | Historical daily prices from Yahoo Finance |
- Downloaded 5 years of daily closing prices for AAPL, MSFT, GOOG, and AMZN using
yfinance.
- Computed daily and annualized returns.
- Calculated the covariance matrix to represent asset co-movements.
- Generated 10,000+ random portfolios with randomized weights.
- Calculated each portfolio’s expected return, volatility, and Sharpe ratio.
- Used Sequential Least Squares Programming (SLSQP) to:
- Maximize Sharpe ratio, identifying the optimal risk-adjusted portfolio.
- Minimize variance, finding the most stable allocation.
- Plotted the efficient frontier showing portfolios that yield the highest return for each level of risk.
- Highlighted:
- 🔴 Max Sharpe Ratio Portfolio
- 🟢 Minimum Variance Portfolio
- Clone and run this repository
git clone https://github.com/evy004/PortfolioSimulation.git cd PortfolioSimulation pip install -r requirements.txt python main.py