By default silence `Client.get_quote()` timeout errors unless caller specifies to raise
parent
2e6b1330f3
commit
2b8cd031e8
|
@ -663,7 +663,7 @@ class Client:
|
|||
|
||||
# commodities
|
||||
elif exch == 'CMDTY': # eg. XAUUSD.CMDTY
|
||||
con_kwargs, bars_kwargs = _adhoc_symbol_map[symbol]
|
||||
con_kwargs, bars_kwargs = _adhoc_symbol_map[symbol.upper()]
|
||||
con = Commodity(**con_kwargs)
|
||||
con.bars_kwargs = bars_kwargs
|
||||
|
||||
|
@ -780,6 +780,7 @@ class Client:
|
|||
self,
|
||||
contract: Contract,
|
||||
timeout: float = 1,
|
||||
raise_on_timeout: bool = False,
|
||||
|
||||
) -> Ticker:
|
||||
'''
|
||||
|
@ -798,10 +799,16 @@ class Client:
|
|||
if isnan(ticker.last):
|
||||
|
||||
# wait for a first update(Event)
|
||||
try:
|
||||
tkr = await asyncio.wait_for(
|
||||
ready,
|
||||
timeout=timeout,
|
||||
)
|
||||
except TimeoutError:
|
||||
if raise_on_timeout:
|
||||
raise
|
||||
return tkr
|
||||
|
||||
if tkr:
|
||||
break
|
||||
else:
|
||||
|
|
|
@ -843,7 +843,10 @@ async def stream_quotes(
|
|||
# TODO: we should instead spawn a task that waits on a feed to start
|
||||
# and let it wait indefinitely..instead of this hard coded stuff.
|
||||
with trio.move_on_after(1):
|
||||
first_ticker = await proxy.get_quote(contract=con)
|
||||
first_ticker = await proxy.get_quote(
|
||||
contract=con,
|
||||
raise_on_timeout=True,
|
||||
)
|
||||
|
||||
# it might be outside regular trading hours so see if we can at
|
||||
# least grab history.
|
||||
|
|
Loading…
Reference in New Issue