From 6e55f6706f692af4c3d6fa2226a8f2b42c24fed3 Mon Sep 17 00:00:00 2001 From: jaredgoldman Date: Tue, 11 Apr 2023 12:59:53 -0400 Subject: [PATCH] Format condition for filtering and add link to docs explaining need for filtering in the first case --- piker/brokers/kucoin.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/piker/brokers/kucoin.py b/piker/brokers/kucoin.py index e05d191a..3f4056a9 100644 --- a/piker/brokers/kucoin.py +++ b/piker/brokers/kucoin.py @@ -566,8 +566,12 @@ async def stream_messages(ws: NoBsWs, sym: str) -> AsyncGenerator[NoBsWs, dict]: case 'trade.ticker': trade_data = KucoinTrade(**msg.data) - # Filter for duplicate messages - if last_trade_data and trade_data.time == last_trade_data.time: + # 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 + ): continue last_trade_data = trade_data