Handle defunct QT tickers and delays

kivy_mainline_and_py3.8
Tyler Goodlet 2018-03-29 13:01:13 -04:00
parent 823bd2ea29
commit 164d636c67
1 changed files with 18 additions and 1 deletions

View File

@ -304,7 +304,24 @@ async def quoter(client: Client, tickers: [str]):
else: else:
raise raise
return {quote['symbol']: quote for quote in quotes_resp['quotes']} # dict packing and post-processing
quotes = {}
for quote in quotes_resp['quotes']:
quotes[quote['symbol']] = quote
if quote.get('delay', 0) > 0:
log.warning(f"Delayed quote:\n{quote}")
return quotes
first_quotes_dict = await get_quote(tickers)
for symbol, quote in first_quotes_dict.items():
if quote['low52w'] is None:
log.warn(f"{symbol} seems to be defunct discarding from tickers")
t2ids.pop(symbol)
# re-save symbol ids cache
ids = ','.join(map(str, t2ids.values()))
yield get_quote yield get_quote