Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
How would I go about screening stocks that have fallen 20% or more in the past day? What about 5 days?

I am looking to grab these stocks, but from what I can see, the screener only supports a static screen, grabbing stocks once and only being able to buy those.

1 response

This can be done with pipeline, using the built-in factor called "Returns". Just set your lookup window to equal "1" or "5". Then you want to apply your -20% filter. It could look something like this, but I haven't debugged or tested this:



def initialize(context):

    # Create and attach an empty Pipeline.  
    pipe = Pipeline()  
    pipe = attach_pipeline(pipe, name='my_pipeline')

    # Construct Factors.  
    return_1days = Returns(inputs=[USEquityPricing.close], window_length=1)  
    return_5days = Returns(inputs=[USEquityPricing.close], window_length=5)

    # Construct a Filter.  
    down20in1 = (return_1days<-0.20)  
    down20in5 = (return_5days<-0.20)

    # Register outputs.  
    pipe.add(return_1days, 'return_1days')  
    pipe.add(return_5days, 'return_5days')

    # Remove rows for which the Filter returns False.  
    pipe.set_screen(down20in1)

Good luck!