Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
How to find similar stocks?

Hi,

I have zero knowledge of fundamental valuation. Can anyone in community help me identify "similar"stocks. i.e. stocks that share similar characteristics using fundamentals? I want to create groups of 30+ similar stocks and trade them. Please advise.

10 responses

Pravin,

Stocks in the same sector that have highly correlated return streams would be a good approach. You could also seek stocks in the same sector with similar leverage ratios .

Thanks Frank. I guess I will have to use clustering to seek stocks in same sector with similar leverage ratios.

Pravin,

Here is a more time intensive approach. Would love to see if you are able to accomplish this task globally using a clustering algo.

That is awesome, thanks Grant.

Credit for the original post to James Jack from back in the early days of Q - https://www.quantopian.com/posts/1st-attempt-finding-co-fluctuating-stocks . You're welcome. --Grant

@Frank - thanks a lot for introducing me to doing this with pipeline. I will try and make it clusterable.
@Grant - thanks for the example.

@Frank - attached is code to find similar stocks by leverage with sector using KMeans clustering algorithm.

Thanks Pravin -

Why are you interested in leverage? Or did you just pick it arbitrarily as an example?

Also, I'd consider if this code handles splits point-in-time properly (I'd be worried that the pricing data aren't aligned in time with the shares_outstanding):

class MarketCap(CustomFactor):  
    inputs = [USEquityPricing.close, morningstar.valuation.shares_outstanding]  
    window_length = 1  
    def compute(self, today, assets, out, close, shares):  
        out[:] = close[-1] * shares[-1]  

I simply use:

market_cap = mstar.valuation.market_cap.latest  

Grant - I picked leverage just for example. Thanks for the market_cap hint.