Skip to content

Define candidates for optimal portfolio using comparison between expected returns and the risk from each stock in the SP500. Then calculate and save the Find the Minimum Variance Portfolio (MVP) optimal weights to CSV files.

Notifications You must be signed in to change notification settings

blkpvnthr/portfolioOpt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SP500 Portfolio Optimization

This repository contains a Python script for performing portfolio optimization on S&P 500 stocks using historical data from Yahoo Finance. The project leverages the yfinance library for data retrieval and PyPortfolioOpt for portfolio optimization, calculating various metrics, expected returns, risk, and covariance matrices.

Project Overview

The main objectives of this project are to:

  1. Download and Analyze S&P 500 Stock Data: Retrieve historical adjusted close prices, calculate daily returns, and analyze key metrics (Expected Return, Standard Deviation, and Variance).
  2. Optimize Portfolio: Using portfolio optimization techniques to find an optimal allocation of weights that maximize the Sharpe Ratio and minimize portfolio volatility.
  3. Generate Custom Covariance Matrix: Calculate the covariance matrix between stocks based on their historical returns.
  4. Identify Optimal Portfolio Candidates: Select stocks with positive expected returns that outweigh their variance for a balanced risk-reward portfolio.

Requirements

  • Python 3.7+
  • Required libraries: pandas, numpy, yfinance, PyPortfolioOpt

Install dependencies via:

pip install yfinance pandas numpy PyPortfolioOpt

About

Define candidates for optimal portfolio using comparison between expected returns and the risk from each stock in the SP500. Then calculate and save the Find the Minimum Variance Portfolio (MVP) optimal weights to CSV files.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages