Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Stop Order Error

Hello Folks,

I am trying to set a stop order for a list of securities after they have been filtered through a pipeline, my primary goal is to simply sell positions once a certain percentage increase in the stocks value and sell if the value falls below some predetermined percentage. I have written the following (morning price is the price at which the stock is purchased):

for security in context.early_purchase:
if security not in open_orders:

            if data.can_trade(security):  

                order_target_percent(security, morning_mass)  

                order_target_percent(security, 0, style=StopOrder(1.025*morning_price))    #  <--- Runtime error  

                order_target_percent(security, 0, style=StopOrder(0.995*morning_price))

Unfortunately this gives the following error:

ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

And a runtime error is listed on the line indicated above with the horizontal arrow. Any suggestions as to what the issue is here?