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.
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?