Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
universe similarity analysis

Finally got this code to run. I'll need to follow up later with an explanation of what it does, but I figured I'd share the result anyway in case someone wants to have a look. --Grant

1 response

The basic idea here is to analyze how much spread there is in the pair-wise similarity of a batch of securities. In this example, the securities are defined by:

set_universe(universe.DollarVolumeUniverse(98, 100))  

On a rolling basis, the 30-day daily closing price history of each security is normalized and level-coded (1, 2, 3, or 4) (as a side note, the coding approach has a striking similarity to Bollinger Bands). The coded prices are then converted into strings, and the strings are compared pairwise across all unique pairs with a similarity metric. For the list of similarity values of all of the pairs, I compute the coefficient of variation (plotted as CV) which is the standard deviation divided by the mean of all of the similarity values. Note that instead of using prices, volumes could be used instead, for example.

Please note that I included several literature and web references in the code above, if you want more detail.

I don't know if this approach will yield any insights...I welcome comments. In any case, I learned a bit more Python, and some interesting analysis techniques.

Grant