There is nothing wrong with your approach, as long as your internal counter gets initialized with the value of the automatic nextValidId() callback you receive when your client connects to TWS API. If your client gets "in contact" with orders from other clients, you need to adjust your interal counter so that it is higher than the orderId of all orders your client sees. That is mostly important for client 0 and the master client since they receive openOrder() callback for orders placed by other clients or TWS in real time, but all clients might need to do that in case they request all open orders, for example, and the list contains order from other clients. The simplest approach is that your openOrder() callback makes sure that your internal counter is always higher than all orderIds it sees. 闯ü谤驳别苍 ?
On Fri, Dec 27, 2024 at 08:03 AM, Marco wrote:
? |