Closed yarimiz closed 2 years ago
I've figured out what happens, so for newcomers facing the same issue, I'm leaving this comment here and closing the issue, as this is not ib_insync bug.
Apparently, if orders are not transmitted (sent with transmit=False
) they won't be picked up by the API. This is not an issue of ib_insync, but an intentional (but not documented, AFAIK) behavior of IB API.
In addition, if during your session you've transmitted an untransmitted order, this won't be picked up automatically by the API (as it wasn't received during the sync operation during the connection). In this case, you'll have to run reqOpenTrades()
to reinitiate the sync.
Nonetheless, please be sure you're using either the same clientId which created the orders or configure a master client id to retrieve orders made by any client.
Just leave it here - this is the real solution even you won't wanna use the same client id or a master id: https://groups.io/g/insync/message/4997
This is the situation I'm at:
After connecting, the client doesn't show open orders made via the API, using the same client id. I've tried using the master client id, client id = 0 any specific client IDs for all the runs.
This is how I'm connecting. client id 999 is configured as master in TWS.
ib.connect("127.0.0.1", config["port"], clientId=999)
I tried connecting with 0, 999 and just 1
Update: If I'm calling openTrades() from within the same session that I made the orders in, it will retrieve the new orders. But, as soon as I restart my app (using with the exact same conditions), calling openTrades() will not retrieve orders made from the previous session.
The flow:
At step 5, I also called reqAllOpenOrders, AllOpenOrders, OpenOrders. All returns empty list.
Needless to say, all orders are yet to be filled. They are all not transmitted yet.
Some more info: I'm using only one client My TWS is connected to a single paper account, without sub-accounts