Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
I am confused with stop limit order

I thought when short selling a stock, if the current price is <= stop price, the stop limit order should be turned into an limit order, the order won't be filled if the following price jump below the limit price. eg: stoplimit(limit= 25.01, stop= 25.03,amount=-100), if current price hit 25.03, the short selling will ensure the order won't be triggered below 25.01.

If I understand correctly, In backtest

order_target_percent(sid,sids[sid]*factor,style=StopLimitOrder(data.current(sid,'price')*0.998,data.current(sid,'price')*1.005))  

should gave a better result compared to

order_target_percent(sid,sids[sid]*factor,style=StopLimitOrder(data.current(sid,'price')*0.998,data.current(sid,'price')))

as the stopprice=data.current(sid,'price')*1.005) is more aggressive . But In my backtest, the 1.005 version actually gave a much worse result.
Edit: a stop price = data.current(sid,'price')*1.1 gave the same result as stop price = data.current(sid,'price') as expected. It fills without looking.
What is going on ??

2 responses

Check my simple backtest. At least The type=4 and type=5 scenario will make a point.

For me,the purpose of stop limit is to guarding the fill price. A natural question is which one is more important, the limit price, or the stop price ?
In my full backtest, the stop price needs to be set 1.003X higher to ensure the order will be triggered.(compare to market order).
Then, the limit price needs to be 0.995X lower to get a similar result compared to market orders. A 0.996X
gave a 3% worse return compared to 0.995X

order_target_percent(sid,sids[sid]*factor,style=StopLimitOrder(data.current(sid,'price')*0.995,data.current(sid,'price')*1.003))  

So,How could I chose the parameters, considering the trade off between a better fill and a bad fill but result in more return?