From 0e4a7e38469b9ccedb375952e4b69e745c22ae81 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Fri, 19 Nov 2021 10:29:04 -0500 Subject: [PATCH] Only warn on slow quote query --- piker/brokers/ib.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/piker/brokers/ib.py b/piker/brokers/ib.py index 248039d4..d9e22d51 100644 --- a/piker/brokers/ib.py +++ b/piker/brokers/ib.py @@ -505,8 +505,14 @@ class Client: ) # ensure a last price gets filled in before we deliver quote - while isnan(ticker.last): - ticker = await ticker.updateEvent + for _ in range(25): + if isnan(ticker.last): + ticker = await ticker.updateEvent + await asyncio.sleep(0.2) + else: + log.warning( + f'Symbol {symbol} is not returning a quote ' + 'it may be outside trading hours?') details = (await details_fute)[0] return contract, ticker, details @@ -1350,10 +1356,11 @@ async def stream_quotes( # TODO: support multiple subscriptions sym = symbols[0] - contract, first_ticker, details = await _trio_run_client_method( - method='get_quote', - symbol=sym, - ) + with trio.fail_after(3): + contract, first_ticker, details = await _trio_run_client_method( + method='get_quote', + symbol=sym, + ) # stream = await start_aio_quote_stream(symbol=sym, contract=contract) async with open_aio_quote_stream(