From 2b51e84a3ca9927bbc32233efb9e2e0458411d32 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 29 Mar 2018 13:02:03 -0400 Subject: [PATCH] Expect quotes dict in watchlist update loop --- piker/ui/watchlist.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/piker/ui/watchlist.py b/piker/ui/watchlist.py index b6bc410c..9f57d708 100644 --- a/piker/ui/watchlist.py +++ b/piker/ui/watchlist.py @@ -349,10 +349,8 @@ async def update_quotes( grid.quote_cache = cache # initial coloring - for quote in first_quotes: - sym = quote['symbol'] + for sym, quote in first_quotes.items(): row = grid.symbols2rows[sym] - # record, displayable = qtconvert(quote, symbol_data=symbol_data) record, displayable = brokermod.format_quote( quote, symbol_data=symbol_data) row.update(record, displayable) @@ -365,12 +363,11 @@ async def update_quotes( while True: log.debug("Waiting on quotes") quotes = await queue.get() # new quotes data only - for quote in quotes: - # record, displayable = qtconvert(quote, symbol_data=symbol_data) + for symbol, quote in quotes.items(): record, displayable = brokermod.format_quote( quote, symbol_data=symbol_data) - row = grid.symbols2rows[record['symbol']] - cache[record['symbol']] = (record, row) + row = grid.symbols2rows[symbol] + cache[symbol] = (record, row) row.update(record, displayable) color_row(row, record) @@ -401,11 +398,10 @@ async def _async_main(name, tickers, brokermod, rate): ) # get first quotes response - pkts = await queue.get() + quotes = await queue.get() first_quotes = [ - # qtconvert(quote, symbol_data=sd)[0] for quote in pkts] 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: 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( - update_quotes, brokermod, widgets, queue, sd, pkts) + update_quotes, brokermod, widgets, queue, sd, quotes)