¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

Re: Avoiding time.sleep while waiting for openOrder / orderStatus callback after placeOrder


 

The issue you are having is an old one in programming.? You have two basic choices: polling and interrupting.? Polling means you check a status, usually in a loop with a sleep or yield call.? Interrupting means you wait on an event from the server, usually received as a callback in IB's API.? The interrupting is better but harder to write.? You usually have to add extra logic to implement a timeout in case the server doesn't respond at all.

For what you are doing, polling is likely far better unless you are a pretty good professional programmer with years of experience.? Just wrap a loop around your logic and you are there.? Probably best to make the loop run at most a set number of times.? The max total wait time will be the number of times the loop can run times the length of the sleep.? You probably want to make the max total wait time to be about 15 seconds (5sec to a minute is reasonable).? I hope this helps.

Hunter

On Sunday, October 8, 2023 at 07:21:29 AM PDT, fran <fchiesadoc@...> wrote:



Check this out.

El 8 oct. 2023, a la(s) 11:02, Lipp F. <flipp31a@...> escribi¨®:

?All code?examples I can see are like this:

placeOrder(orderId, contract, order)
time.sleep(10)
Is there a better way of doing this? Maybe using?threading.Lock() with release() in callback functions? Looking for an example. TIA.
?

Join [email protected] to automatically receive all group messages.