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.
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.
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!