开云体育

ctrl + shift + ? for shortcuts
© 2025 开云体育

Re: next valid id on initial connection


 

thank you for the fast reply.

honesty I got lost in i
I'm a?junior so my?knowledge is?quite?limited for now, so I'm not sure how to wait for a callback in python.
but i did find an example online?related to this?matter
is that a good solution?

? ? def nextValidId(self, orderId: int):
? ? ? ? super().nextValidId(orderId)
? ? ? ? self._next_order_id = orderId

def main():

? ? testApp = IBApi()
? ? #connect on separet thred
? ? testApp.connect("127.0.0.1", 7496,1)
? ? t = threading.Thread(target=testApp.run, daemon=True)
? ? t.start()
? ? #if connection is done continue
? ? while True:
? ? ? ? if isinstance(testApp._next_order_id, int):
? ? ? ? ? ? print("connected")
? ? ? ? ? ? break
? ? ? ? else:
? ? ? ? ? ? print("waiting for connection")
? ? ? ? ? ? time.sleep(1)

thank you so much,
Cohav

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