Voyz / ibind

IBind is a REST and WebSocket client library for Interactive Brokers Client Portal Web API.
Apache License 2.0
113 stars 14 forks source link

live_orders() and 'filters' performance #12

Closed zacciep closed 3 weeks ago

zacciep commented 5 months ago

When using filters and the live_orders() method I am getting incomplete results. I have tried this across a variety of filter configurations. It appears that IBKR gateway is not returning the complete results when a filter request is made (I cannot see anywhere in IBind that may be further filtering the response). I have resorted to getting all orders and post filtering myself (hoping that this is more reliable).

In addition I often seem to get inconsistent responses on the first call or two to this function (and similarly with other interface functions such as live_marketdata_snapshot). The server seems to need some time to "warm up"!? Not entirely repeatable, so hard to pinpoint the issue.

Voyz commented 5 months ago

I've been seeing similar results on my end. I think that they have some type of caching on their end that isn't updated when it needs to. I spoke to IBKR support about it but since this is really hard to replicate we didn't get far. It has stopped happening to me for some time hence I assumed it has been solved; I'm sad to see it still an issue.

I'd suggest you raise this with IBKR support to in order for them to have more datapoints.

And to clarify - indeed IBind is not filtering these results in any way.

zdytch commented 4 months ago

Same behavior for me. My current approach may seem awkward, but it seems to return a consistent result. If you know a better solution, please write here.

My approach is:

  1. Request "orders" endpoint with desirable "filters" and "force=true". This resets cache on server side and returns an empty list, which is ok.

  2. Wait for N seconds not to abuse IB's pacing limitation. Not sure what number goes best here. In my case, I use 5, as the "Pacing Limitation" section says "1 req/5 secs" for orders endpoint: https://ibkrcampus.com/ibkr-api-page/cpapi-v1/#pacing-limitations

But for fast strategies that might be unacceptable

  1. Re-request "orders" endpoint with the same "filters" as on step 1, but W/O "force". This returns fresh order list
Voyz commented 3 weeks ago

I'm going to close this issue due to inactivity. Thanks for your contribution and please feel free to request a reopen if you'd like to continue the discussion 👍