Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Data for Correlation Matrix

Anyone know a simple to pull up correlation and volatility data for a small subset of securities?

3 responses

I haven't done it here in quantopian however in ipython I have use the following code to get the correlation matrix you need to use pandas

df = pd.io.data.get_data_yahoo(stocks,start=startdate,end=enddate)['Adj Close']  
# Calculate daily returns for the Tickers in the DataFrame  
rets = df.pct_change()  
# Calculate the Correlation for the daily returns of the Tickers  
corr = rets.corr()  

Not sure exactly what you are after, but maybe this example will help:

https://www.quantopian.com/posts/long-only-minimum-variance-portfolio-using-scipy-dot-optimize-dot-minimize

Grant

Grant,

I was wanting to compare performance between risk parity, minimum variance, and minimum correlation portfolios. I had looked around Q for an MVP example ...hadn't found one ...so the example you referred me to is awesome. Perfect for and MVP comparison.

Alex's recent post of David Varadi's implementation with percentile channels and risk parity where all assets are held in the portfolio in proportion to the inverse of their respective volatility has really nice metrics.

Varadi's "Minimum Correlation 2" portfolio essentially attempts to concomitantly minimize volatility and correlation. His white paper on that is here.

Thanks, again, Grant. This helps a lot.

Stephen