From 29be7f58c99bbcbb9dedf24ed0badb74c5dd39fe Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Tue, 13 Feb 2018 15:35:21 -0500 Subject: [PATCH] Push every new change; not just the last trade --- piker/brokers/questrade.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/piker/brokers/questrade.py b/piker/brokers/questrade.py index 3f7cee8b..caaa9c65 100644 --- a/piker/brokers/questrade.py +++ b/piker/brokers/questrade.py @@ -301,7 +301,7 @@ async def poll_tickers( client: Client, tickers: [str], q: trio.Queue, rate: int = 5, # 200ms delay between quotes - time_cached: bool = True, # only deliver "new" quotes to the queue + diff_cached: bool = True, # only deliver "new" quotes to the queue ) -> None: """Stream quotes for a sequence of tickers at the given ``rate`` per second. @@ -323,14 +323,14 @@ async def poll_tickers( if quote['delay'] > 0: log.warning(f"Delayed quote:\n{quote}") - if time_cached: # if cache is enabled then only deliver "new" changes + if diff_cached: + # if cache is enabled then only deliver "new" changes symbol = quote['symbol'] last = _cache.setdefault(symbol, {}) - timekey = 'lastTradeTime' - if quote[timekey] != last.get(timekey): - new = set(quote.items()) - set(last.items()) + new = set(quote.items()) - set(last.items()) + if new: log.info( - f"New quote {quote['symbol']} @ {quote[timekey]}:\n{new}") + f"New quote {quote['symbol']}:\n{new}") _cache[symbol] = quote payload.append(quote) else: