Back to Community
Pipeline for finding closely correlated stocks?


I am looking to build a pipeline to select pairs of closely correlated stocks from the general stock market for a paired mean-reversion algorithm I have been working on, yet none of my research has found anything to assist me with this problem. Please note that I am very much a beginner, but have some experience with python prior to using Quantopian. Please answer ASAP.



2 responses

You could run a correlation matrix fairly easily on a set of .csv files using pandas:

You can download the .csv files from yahoo finance fairly easily and then using the correlation matrix function you could rank them by how closely they are correlated.

One thing I failed to mention, it is important to use the log returns and not absolute returns when doing the correlation study.