From bedbbc3025494d07424d1c733a8074f03f2bc23a Mon Sep 17 00:00:00 2001 From: jaredgoldman Date: Tue, 11 Apr 2023 13:45:32 -0400 Subject: [PATCH] Only diff trade time --- piker/brokers/kucoin.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/piker/brokers/kucoin.py b/piker/brokers/kucoin.py index 3f4056a9..b6fef60f 100644 --- a/piker/brokers/kucoin.py +++ b/piker/brokers/kucoin.py @@ -546,7 +546,7 @@ def make_sub(sym, connect_id, level='l1') -> dict[str, str | bool]: async def stream_messages(ws: NoBsWs, sym: str) -> AsyncGenerator[NoBsWs, dict]: timeouts = 0 - last_trade_data: KucoinTrade | dict = {} + last_trade_ts = 0 while True: with trio.move_on_after(3) as cs: @@ -568,13 +568,10 @@ async def stream_messages(ws: NoBsWs, sym: str) -> AsyncGenerator[NoBsWs, dict]: # XXX: Filter for duplicate messages as ws feed will send duplicate market state # https://docs.kucoin.com/#level2-5-best-ask-bid-orders - if ( - last_trade_data - and trade_data.time == last_trade_data.time - ): + if trade_data.time == last_trade_ts: continue - last_trade_data = trade_data + last_trade_ts = trade_data.time yield 'trade', { 'symbol': sym,