Keyboard Shortcuts
Likes
Search
Erroneous execution details (execDetails) being returned
Hey All,
I'm curious if anyone else has experienced problems with the Execution details (execDetails) being returned from the TWS API. I'm using the C# version. Intermittently I've been getting completely erroneous values being returned when orders haven't actually been executed at all and duplicate execution details for the same order Id that differ.? Here's an example: ExecDetails. -1 - NQ, FUT, USD - 0000e1a7.6310667f.01.01, 14098, 1, Added Liquidity, 12044.25, 20220901? 08:23:04permId: 843004273
ExecDetails. -1 - NQ, FUT, USD - 0000e1a7.63106809.01.01, 14101, 1, Added Liquidity, 12044.25, 20220901? 08:27:04permId: 843004608
ExecDetails. -1 - NQ, FUT, USD - 0000e1a7.63106bc1.01.01, 14103, 1, Added Liquidity, 12075.5, 20220901? 08:35:17permId: 843004610
ExecDetails. -1 - NQ, FUT, USD - 0000e1a7.63106c03.01.01, 14100, 1, Added Liquidity, 12082, 20220901? 08:35:40permId: 843004275
ExecDetails. -1 - NQ, FUT, USD - 0000e1a7.630f1c3d.01.01, 14098, 1, Added Liquidity, 12336, 20220831? 08:27:46permId: 916490259
ExecDetails. -1 - NQ, FUT, USD - 0000e1a7.630f2076.01.01, 14100, 1, Added Liquidity, 12368.5, 20220831? 08:36:47permId: 916490261 Any thoughts or helpful advice on how to fix this would be very appreciated! Thanks, Ryan |
||||
You might want to re-read the TWS API Guide sections on and the class, Ryan. There are several cases where you would get multiple callbacks for a single order placed via the API. Here for example a sliver of the
definition:
The six ExecDetails you listed have unique ExecIds but they all end in ".01". That suggests that each ExecDetails describes an order fill:
Also, please observe that the six permIds are unique as well. That suggests that there were a total of 6 fills for 4 orders you places via the API. Have you cross checked the ExecDetails with the TWS Trade History window? These ExecDetails by themselves and without more context (such as what the placed orders looked like and maybe order status updates) do not look erroneous or duplicate to me. There may be more to the story, but does that make sense? ´³¨¹°ù²µ±ð²Ô |
||||
So it looks like what happened is the orderId got reused for some reason. ExecDetails shows orderId 14100 happening yesterday at 08:36 and today at 08:35. Is it my responsibility to ensure the orderId isn't getting reused? I'm just using the eWrapper.NextValidId which seems to indicate TWS is tracking which orderIds have been used and I shouldn't need to worry about it as long as I'm calling their method, right?
|
||||
¿ªÔÆÌåÓýNo, NextValidId occurs once when you connect to the API. It tells you the first unused order ID for the current ClientID. For each new order, you have to then increment the order id in some fashion so that it¡¯s higher than previous order ids. The API does not automatically provide you with order ids. ? If you use the same order id as has been used in a previous order using the same ClientID, placeOrder will simply modify the existing order (if it hasn¡¯t already been filled), not create a new one. ? And note that different ClientIds can create orders with the same order id. So if you had orders with the same order id yesterday and today, they were presumably created under different ClientIDs. ? All of this is explained in the IB API documentation. It¡¯s worth your while reading it and making sure you understand it. ? Richard ? ? From: [email protected] <[email protected]> On Behalf Of ryanabbott22@...
Sent: 01 September 2022 22:04 To: [email protected] Subject: Re: [TWS API] Erroneous execution details (execDetails) being returned ? So it looks like what happened is the orderId got reused for some reason. ExecDetails shows orderId 14100 happening yesterday at 08:36 and today at 08:35. Is it my responsibility to ensure the orderId isn't getting reused? I'm just using the eWrapper.NextValidId which seems to indicate TWS is tracking which orderIds have been used and I shouldn't need to worry about it as long as I'm calling their method, right? |