Expect quotes dict in watchlist update loop

kivy_mainline_and_py3.8
Tyler Goodlet 2018-03-29 13:02:03 -04:00
parent 164d636c67
commit 2b51e84a3c
1 changed files with 7 additions and 11 deletions

View File

@ -349,10 +349,8 @@ async def update_quotes(
grid.quote_cache = cache grid.quote_cache = cache
# initial coloring # initial coloring
for quote in first_quotes: for sym, quote in first_quotes.items():
sym = quote['symbol']
row = grid.symbols2rows[sym] row = grid.symbols2rows[sym]
# record, displayable = qtconvert(quote, symbol_data=symbol_data)
record, displayable = brokermod.format_quote( record, displayable = brokermod.format_quote(
quote, symbol_data=symbol_data) quote, symbol_data=symbol_data)
row.update(record, displayable) row.update(record, displayable)
@ -365,12 +363,11 @@ async def update_quotes(
while True: while True:
log.debug("Waiting on quotes") log.debug("Waiting on quotes")
quotes = await queue.get() # new quotes data only quotes = await queue.get() # new quotes data only
for quote in quotes: for symbol, quote in quotes.items():
# record, displayable = qtconvert(quote, symbol_data=symbol_data)
record, displayable = brokermod.format_quote( record, displayable = brokermod.format_quote(
quote, symbol_data=symbol_data) quote, symbol_data=symbol_data)
row = grid.symbols2rows[record['symbol']] row = grid.symbols2rows[symbol]
cache[record['symbol']] = (record, row) cache[symbol] = (record, row)
row.update(record, displayable) row.update(record, displayable)
color_row(row, record) color_row(row, record)
@ -401,11 +398,10 @@ async def _async_main(name, tickers, brokermod, rate):
) )
# get first quotes response # get first quotes response
pkts = await queue.get() quotes = await queue.get()
first_quotes = [ first_quotes = [
# qtconvert(quote, symbol_data=sd)[0] for quote in pkts]
brokermod.format_quote(quote, symbol_data=sd)[0] brokermod.format_quote(quote, symbol_data=sd)[0]
for quote in pkts] for quote in quotes.values()]
if first_quotes[0].get('last') is None: if first_quotes[0].get('last') is None:
log.error("Broker API is down temporarily") log.error("Broker API is down temporarily")
@ -463,4 +459,4 @@ async def _async_main(name, tickers, brokermod, rate):
} }
nursery.start_soon(run_kivy, widgets['root'], nursery) nursery.start_soon(run_kivy, widgets['root'], nursery)
nursery.start_soon( nursery.start_soon(
update_quotes, brokermod, widgets, queue, sd, pkts) update_quotes, brokermod, widgets, queue, sd, quotes)