erdewit / ib_insync

Python sync/async framework for Interactive Brokers API
BSD 2-Clause "Simplified" License
2.75k stars 723 forks source link

Manual orders order status #11

Closed mdelvaux closed 6 years ago

mdelvaux commented 6 years ago

The IB API allows to forward messages related to manual orders to a designated client, identified by the "Master API client ID" in TWS (or IB gateway) settings. When the ib_insync client is identified as the designated client, the messages received are not correctly recognized, I see the following error reported

ERROR:ib_insync.wrapper:orderStatus: No order found for orderId 0 and clientId 0 ERROR:ib_insync.wrapper:orderStatus: No order found for orderId 0 and clientId 0 ERROR:ib_insync.wrapper:orderStatus: No order found for orderId 0 and clientId 0

There are multiple errors because there are multiple status messages for each order. Surprisingly all orders seem also tagged with the same orderId, i.e. a later message will get the same orderId. It is my first time experimenting with such a designated client, so I am not really sure about the expected format of the messages, i.e. how can messages be grouped meaningfully if they all have the same orderId.

I am not sure what would be the best method to handle these, possibly:

erdewit commented 6 years ago

The code has been updated so that manually submitted orders or orders from other API clients are now ignored.