Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Comparing today's factor results versus previous days' factor results

Greetings,

I'd like to test whether the current daily range is narrower than the previous six days’ daily ranges compared individually. I have used the simple price range factor as provided in the docs:

class PriceRange(CustomFactor):  
    """  
    Computes the difference between the highest high and the lowest  
    low of each over an arbitrary input range.  
    """  
    inputs = [USEquityPricing.high, USEquityPricing.low]

    def compute(self, today, assets, out, highs, lows):  
        out[:] = np.nanmax(highs, axis=0) - np.nanmin(lows, axis=0)  

In my initialize method, I've created the factor and added it to the pipeline:

pipe = attach_pipeline(Pipeline(), name='n7')  
price_range_factor = PriceRange(window_length = 6)  
pipe.add(price_range_factor, 'price_range_factor')  

How would I go about screening the universe for those with the current daily range being narrower than the previous six days’ daily ranges compared individually?