Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Correlation between the top US equities over time

This notebook calculates the weighted correlations of top US equities over time. Correlation here is the Pearson correlation, which is a measure of how similar two sets of returns are. For example, two stocks with returns that are exactly the same over the past 6 months will have a correlation of 1.0, and two stocks with returns that are completely unrelated will have a correlation close to zero.

For each day over the past 15 years it grabs the top 100, 500, etc. US equities, and calculates their correlations between each other. Then the notebook weights all the correlations by market cap, calculates the mean correlation each day, and plots it.

The interesting plots are at the bottom. We can see that the recent overall correlation is low. This means that recently, stock returns have been more diversified and unrelated to each other.

Feel free to look through the code and build upon it!

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

4 responses

Hi Gus,
This is very nice and a great basis for further work.
Many thanks, Tony

Hi Gus -

You might consider how much of the total market cap is represented by the top 10. This would put your final plot into context. If the top 10 only represent a small fraction of the overall market cap, then it is not so exciting. However, if the top 10 represent a significant fraction of the overall market cap, then it is a big deal.

Thanks Tony.

That's a good idea Grant, correlation broken out into quantiles by dollars would be interesting to see. Looking at it by trading volume could be interesting as well.

Hi Gus,
When i did this work myself (several times over the years) I found that the correlation values obtained were in some cases quite sensitive to the length of the correlation window used. For example any pair of securities may be quite closely correlated over a short time-span but less correlated over a longer timeframe, OR vice versa. My solution was to take multiple different correlation lengths and then either compare & contrast them to try to understand what was happening, or else average the different length correl values to obtain some sort of "effective, average" correlation value for each pair. Could I suggest that this may also be a worthwhile exercise if you are interested / have time to look at it.
Best wishes, Tony.