From 026c5f4b522c2ece19f5aa5752075e8f2a71976d Mon Sep 17 00:00:00 2001 From: shane_mai Date: Wed, 11 Jan 2023 14:50:30 +0800 Subject: [PATCH] fix binance ticker websocket with symbol --- .../Exchanges/BinanceGroup/BinanceGroupCommon.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/ExchangeSharp/API/Exchanges/BinanceGroup/BinanceGroupCommon.cs b/src/ExchangeSharp/API/Exchanges/BinanceGroup/BinanceGroupCommon.cs index 1eefe5e0..40bb6f65 100644 --- a/src/ExchangeSharp/API/Exchanges/BinanceGroup/BinanceGroupCommon.cs +++ b/src/ExchangeSharp/API/Exchanges/BinanceGroup/BinanceGroupCommon.cs @@ -269,11 +269,21 @@ protected override async Task OnGetTickersWebSocketAsync(Action> tickerList = new List>(); ExchangeTicker ticker; - foreach (JToken childToken in token["data"]) + + // if it is the tickers stream, data will be an array, else it is an direct item. + var data = token["data"]; + if (data is JArray) + foreach (JToken childToken in data) + { + ticker = await ParseTickerWebSocketAsync(childToken); + tickerList.Add(new KeyValuePair(ticker.MarketSymbol, ticker)); + } + else { - ticker = await ParseTickerWebSocketAsync(childToken); + ticker = await ParseTickerWebSocketAsync(data); tickerList.Add(new KeyValuePair(ticker.MarketSymbol, ticker)); } + if (tickerList.Count != 0) { callback(tickerList);