You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Portfolio Diversification: Correlation Risk Management with Python
Understanding the importance of diversification and a portfolio of uncorrelated returns, I plotted the 5-year returns of several equities, ETFs, and commodities against SPY.
I also used linear regression to calculate the beta and correlation, and generated a correlation matrix and a heatmap.
Procedure
Imported 5-Year adjusted closing prices of my stock investments using Yahoo Finance
Extracted percent change using NumPy
Used linear regression to calculate slope (beta) and correlation
Plotted % returns and linear regression line
Created a correlation matrix and heatmap
Screenshot of Maxtrix and heatmap Generated
Inspiration
David Ng, Professor of Finance, Cornell University - Taught my Finance Analytics Class