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.

Clone Algorithm
6
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 57c1d1013681240ffec73476
There was a runtime error.

See also http://scikit-learn.org/stable/auto_examples/applications/plot_stock_market.html.

Clone Algorithm
75
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 57c1d709c806271003579eac
There was a runtime error.

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.

Clone Algorithm
12
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 57c2882eca6b9510040c8d0e
There was a runtime error.

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.