How to guarantee the success of order deletion
Posted: Fri Feb 05, 2021 12:48 pm
Hi,
When deleting an order, normally it's deleted quickly. However I met a situation where I sent the deletion signal, and the order was not really deleted. On the next tick, my code still finds the order by ibgCreateOrderSnapshot. (Finally, the order got deleted in around 20 seconds)
My own position management logic has sth to do with the existing order (sth like: if the tp/sl order exists, then close the position and delete the associated tp/sl orders), hence the system tried to close the position (by making a reversed market order) the 2nd time, which resulted in an open position of the opposite direction without any protection. I would have taken a significant loss if the price went against me.
My question is: is there some way in your best practice to guarantee the deletion of the order, or to let me know the order deletion is either in progress or failed so I can handle my position management properly?
Thanks in advance.
When deleting an order, normally it's deleted quickly. However I met a situation where I sent the deletion signal, and the order was not really deleted. On the next tick, my code still finds the order by ibgCreateOrderSnapshot. (Finally, the order got deleted in around 20 seconds)
My own position management logic has sth to do with the existing order (sth like: if the tp/sl order exists, then close the position and delete the associated tp/sl orders), hence the system tried to close the position (by making a reversed market order) the 2nd time, which resulted in an open position of the opposite direction without any protection. I would have taken a significant loss if the price went against me.
My question is: is there some way in your best practice to guarantee the deletion of the order, or to let me know the order deletion is either in progress or failed so I can handle my position management properly?
Thanks in advance.