Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Find stocks with a volume spike

Hi there,
I am wondering what the best way to detect volume spikes would be?
I was thinking about looping over all stocks from a certain index (like S&P 500) and analyse volume stock by stock and repeat that every few hours.
I think there must be a better way - do you know any?
Thanky very much for your ideas!
Massi

2 responses

Massi,
you can use the history function to get a trailing window of volumes into one dataframe. In general, the history function will be the best way to get data into one place for analysis. I don't have any suggestions about how to define the actual volume spike though. Keep in mind that the volume is unsigned, so there is no indication if the buyer or seller initiated the trade.

def handle_data(context, data):  
    # Volume for the last hour of trades.  
    volume = history(60, '1m', 'volume')  

David, thanks a lot!