Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Find 30 days high stock

I want to filter stock that is in 30 days high in close price yesterday. Below are my code. However, it gets zero stock picked.
What's wrong with it?

class High(CustomFactor):  
    window_length = 31  
    inputs = [USEquityPricing.close]  
    def compute(self, today, asset_ids, out, close_prices):  
        range_max = np.max(close_prices, axis=0)  
        out[:]  = close_prices[-1] - range_max  
high_diff = High()

high_filter = high_diff == 0  
2 responses

Try this way:

high_filter = high_diff.eq(0)  

(334, 0)

or

range_max = np.max(close_prices[:-1], axis=0)  
high_filter = high_diff >= 0  

(334, 0)

Thanks, Vladimir.