How execute a close order with a Stop Loss in place (without waiting another "next")
-
Is it possible to self.close() when you have an open Stop order, without running the risk of the Stop and Close executing at the same time (and resulting in an unwanted net short position)?
It seems you have to first cancel the Stop, then wait until the next "next" iteration to "Close" the position. But working with daily data, this means up to 3 days before you can get out of the market.
I have tried self.cancel followed by self.Close in the one Next() iteration, but if the Stop has not yet been Accepted by the Broker (i.e. was recently created), it appears this "self.cancel" step doesn't work (and you have to wait another next iteration).
Would love anyone's thoughts on how to manage stops without waiting multiple "next" iterations!
-
@cwse said in How execute a close order with a Stop Loss in place (without waiting another "next"):
I have tried self.cancel followed by self.Close in the one Next() iteration, but if the Stop has not yet been Accepted by the Broker (i.e. was recently created), it appears this "self.cancel" step doesn't work (and you have to wait another next iteration).
This is plainly wrong. Unless "recently" means you have created it in the same iteration, in which case your logic is flawed, because you create and cancel an order in the same iteration.
In any other case the broker will accept orders before you have your chance in
next
.@cwse said in How execute a close order with a Stop Loss in place (without waiting another "next"):
It seems you have to first cancel the Stop, then wait until the next "next" iteration to "Close" the position. But working with daily data, this means up to 3 days before you can get out of the market.
It seems wrongly. Cancel the stop and issue a close.