ib_async
ib_async copied to clipboard
how to use the `ticker.updateEvent` method
i have a code like this:
async def wait_for_midpoint_price(self, ticker: Ticker, wait_time: int) -> bool:
event = asyncio.Event()
def onTicker(ticker: Ticker) -> None:
if not util.isNan(ticker.midpoint()):
event.set()
ticker.updateEvent += onTicker
try:
await asyncio.wait_for(event.wait(), timeout=wait_time)
return True
except asyncio.TimeoutError:
return False
finally:
ticker.updateEvent -= onTicker
however, I got some Python type error:
Cannot assign to attribute "updateEvent" for class "Ticker"
Expression of type "Event" cannot be assigned to attribute "updateEvent" of class "Ticker"
"Event" is not assignable to "TickerUpdateEvent"
just wondering is this the right way to use the updateEvent handler?
here you have an example https://nbviewer.org/github/ib-api-reloaded/ib_async/blob/main/notebooks/tick_data.ipynb