Keyboard Shortcuts
Likes
Search
conflicting orderStatus messages
Has anyone experienced this?
2023-11-07 09:32:22,778 [INFO? ? ] __main__: Order Executed: -1 QQQ STK USD 00025b49.6549ea2c.01.01 97536 100 2 2023-11-07 09:32:22,791 [INFO? ? ] __main__: orderStatus - orderid: 97536 status: Filled filled: 100 remaining: 0 lastFillPrice: 370.13 permId: 900345789 parentId: 0 clientId: 123 2023-11-07 09:32:22,923 [INFO? ? ] __main__: orderStatus - orderid: 97536 status: Cancelled filled: 0 remaining: 0 lastFillPrice: 370.13 permId: 900345789 parentId: 0 clientId: 123 The order was actually executed, so why the 'Cancelled' status confirmation? |
on the Cancelled: filled and remaining are 0 , so I won't be bothered, everything reported is consistent. I can speculate at 09:32 that there are a lot of action on QQQ, |
You give us very little to work with. For example, was this order in an OCA group with other orders, or did it have an Order Condition that could have caused a cancellation, ... Gordon pointed you to the right places for some background. The first sentence of "Considerations for Automated Systems" is probably one of the most important considerations where its says "... it is important to monitor for callback notifications, specifically for When we get a "Cancelled" order status (for example from a "self destruct" price condition on limit orders, an OCA group, or order cancellation request) we always get an error 202 callback (more an informational message than an error). errorMsg in that callback usually contains the reason for the cancellation. Any chance you have logged that, too? ´³¨¹°ù²µ±ð²Ô On Tue, Nov 7, 2023 at 08:41 AM, bespalex wrote:
Has anyone experienced this? |
Here is what I got in terms of corresponding errors:
97536,201,Order rejected - reason:Order is already filled,,1699367542.897107,2023-11-07 09:32:22.897107 97536,104,Cannot modify a filled order.,,1699367542.930087,2023-11-07 09:32:22.930087 The order was a simple order, no groups, nothing else. Yes, in my experience execDetails always comes first, and contains the most fields I need, openOrder and orderStatus usually come some 200ms or so later, often in doubles, and sometimes contradictory, like this one. |
From my perspective what you describe look strange. |
Let's clarify a point: I will be really astonished that IB send ::execDetails before ::openOrder
However callbacks are asynchronous. So what I wrote above is "generally" the sequence to expect. I guess that IB does try to respect a certain sequence and their messaging system are a queue, so they can control this. However their doc doesn't explicitly says that they are committed to respect a specific sequence. Always be ready for an execution out of sequence and you can only safely rely on receiving one openOrder call back, but not more. (read para on orderStatus) and in due time ::execDetails. |
This is not manual. Of course, pre-submitted and submitted statuses are also coming when relevant.
What happened is a failed price modification attempt. PlaceOrder is sent with a new price and the same id for modification, it happens to be just executed, hence the rejection. But there should not be a cancellation as the original orderId is executed, but the 'new' duplicate one is rejected. This is my understanding it should be submitted first before it can be cancelled. And if we assume the order was somehow considered 'new' by IB there should be a duplicate id error instead. |
On Thu, Nov 9, 2023 at 05:20 AM, bespalex wrote:
And yes, I always get openOrder with Filled status after execDetails, even if with a few ms delay.Ok, I dodn't have same experience but I my understanding of the documentation doesn't suggest that what your experience is an impossible sequence. I am under the impression that openOrder is a 'local traffic' (TWS/GTB to Client) hence may answer faster than execDetails which require a lot of remote actions. I am not surprised that you get a "filled" status for the openOrder after the?execDetails , I am surprised that you don't get anything like "PreSubmitted" before, like as soon as you submit the placeOrder as IB doc implied it |
On Thu, Nov 9, 2023 at 05:08 AM, bespalex wrote:
This is not manual. Of course, pre-submitted and submitted statuses are also coming when relevant. You mean error 103 ? |
Indeed place and cancel is more expensive in terms of time, as it takes more to verify the order's been actually cancelled. And if skip the wait, I have seen multiple orders executed instead of one, because the cancellation never went through, but ended up with execution. On the other hand, modification is cheap, as the worst case scenario is modification rejection which is easy to handle and doesn't hurt me. Also considering the message flow cap, modification is a preferred choice. So far I mostly get errors 104 and 10148, and occasionally 103 too.
|