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

Hi,

I tried the following code for stop loss:

# while e is Equity(11999 [AZPN]) or some other equity  
amount = 683  
sl = 71.176125

algo.order(e, amount)  
algo.order(e, -amount, stop_price = sl)  

I'm getting runtime error at the last row (setting stop loss).
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()

Any one has any idea what went wrong?

3 responses

Try this:

 order(e, -amount, style=StopOrder(sl))  

Hi Vladimir,

I've tried your suggestion. Same error.

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

The best way to get help fast is to attach backtest with your problem.