brndnmtthws / thetagang

ThetaGang is an IBKR bot for collecting money
GNU Affero General Public License v3.0
1.96k stars 261 forks source link

Exhausted retries waiting on predicate. #333

Closed robby28-11 closed 10 months ago

robby28-11 commented 10 months ago

Getting since a few days errors (Exhausted retries waiting on predicate.) in the log File but all the orders are beeing created correctly.

Not sure why this is happening now. Any ideas?

thetagang-2023-11-22T17-34-04.log

brndnmtthws commented 10 months ago

In this particular case, it looks like thetagang is waiting for the order status to change from PendingSubmit or PreSubmitted to Submitted. Looks like the issue is with MGA, but I can't really tell you why the order isn't submitting. In this particular case it might be a harmless error/delay, assuming the order does eventually submit. Thetagang is a bit strict in that it waits for the orders to reach a submitted state before proceeding, which might occasionally result in this error.

One option is to increase the amount of time it will wait for the API by adjusting the ib_insync.api_response_wait_time value in thetagang.toml, which is 60s by default. You could try 90 or 120s if you keep hitting this. Note that this affects all API calls, so it could introduce unwanted delays elsewhere.

In my experience, this happens sometimes with any lower volume stocks/ETFs (for whatever reason IBKR waits to submit the order to an exchange, and I suppose it does this to avoid bad fills or because they're waiting to sell the order flow for a bit of $$$).

There's a little more information on the order statuses (under the header "Possible Order States") here: https://interactivebrokers.github.io/tws-api/order_submission.html

robby28-11 commented 10 months ago

Already changed that to 120, but it still threw the error. Nevertheless the orders were transmitted to IBKR. Haven't seen the error with the orders afterwards.