Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Pipeline find stock has yesterday unsual compare to average

Hello,
It is my first post here. I am testing api here to make a new strategy, however I have a problem to calculate the average volume before yesterday session. So then I will be able to find a stock which has a huge volume compare to average, but when I test my code in notepad the calculation is the same for all stocks which are wired. What am I missing?

class AvgVolume(CustomFactor):  
    inputs = [USEquityPricing.volume]  
    def compute(self, today, assets, out, volumes):  
        out[:] = volumes[:-1].mean()

pipe = Pipeline()

# Factor of yesterday's close price.  
yesterday_volume = USEquityPricing.volume.latest  
yesterday_price = USEquityPricing.close.latest

avg_volumes_5 = AvgVolume(window_length=6)

pipe.add(yesterday_volume, 'volume')  
pipe.add(avg_volumes_5, 'avg_volumes_5')  
pipe.add(BusinessDaysSincePreviousEarnings(), 'earnings')  
universe = QTradableStocksUS()