Dear friends,
Let’s say I have a listing order waiting to sell a certain instrument on the stock market.
If I run the OrderSendAsync () command to cancel this order, and shortly after that I run another OrderSendAsync () command to send a buy order to the market for the same instrument, is it guaranteed that my sell limit will be canceled before my market is bought the order is executed?
Is there a chance that the OrderSendAsync () commands are executed out of order, and my limit on putting up for sale is canceled by my purchase order in the market before it is canceled?
What if I use OrderSend () instead of OrderSendAsync ()?
ps: of course, I could just poll the pending sale status and wait for the cancellation to be confirmed before sending the sales order to the market, but due to performance requirements, I need the evacuation time between canceling the sales order and sending the purchase order as short as possible so that OrderSendAsync () would be preferable to OrderSend () if the desired sequence of events could be guaranteed.
trader_patinhas
@ Andrew Khotimliansky , @ Vasily Sokolov
Thank you so much for your answers!
Waiting for the TradeTransaction event confirming the cancellation of the previous order will be bad news for me, because I need the time interval between canceling the first order and sending the second one to be as short as possible.
I hope the problem can be solved by simply changing OrderSendAsync () to OrderSend (), but that seems like an illusion.
From what I understand from your answers (I can’t speak Russian and rely on automatic translation for reading and writing), it seems that TCP / IP networks (the Internet in General) they cannot guarantee that data packets arrive in the same order as they are sent. So the commands to cancel the previous order and to send a new order can be received out of order on the server, right?
Life is very hard!
Thank you guys!
c-4
There is no such guarantee. Note, however, that in Your case, a pending order can be canceled both BEFORE entering the market and AFTER it. The main thing is that the pending order does not work during the placement of the second order.
komposter
Good question.
There are no guarantees.
At least because the first OrderSendAsync may get lost on the way to the server, and the second will reach earlier.
If you need to delete an order and then enter the market, use OrderSend or OrderSendAsync with the result analysis in OnTradeTransaction.