Skip to content

Commit 1686831

Browse files
authored
fix binance ticker websocket with symbol (#794)
1 parent a23becb commit 1686831

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/ExchangeSharp/API/Exchanges/BinanceGroup/BinanceGroupCommon.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,11 +269,21 @@ protected override async Task<IWebSocket> OnGetTickersWebSocketAsync(Action<IRea
269269
JToken token = JToken.Parse(msg.ToStringFromUTF8());
270270
List<KeyValuePair<string, ExchangeTicker>> tickerList = new List<KeyValuePair<string, ExchangeTicker>>();
271271
ExchangeTicker ticker;
272-
foreach (JToken childToken in token["data"])
272+
273+
// if it is the tickers stream, data will be an array, else it is an direct item.
274+
var data = token["data"];
275+
if (data is JArray)
276+
foreach (JToken childToken in data)
277+
{
278+
ticker = await ParseTickerWebSocketAsync(childToken);
279+
tickerList.Add(new KeyValuePair<string, ExchangeTicker>(ticker.MarketSymbol, ticker));
280+
}
281+
else
273282
{
274-
ticker = await ParseTickerWebSocketAsync(childToken);
283+
ticker = await ParseTickerWebSocketAsync(data);
275284
tickerList.Add(new KeyValuePair<string, ExchangeTicker>(ticker.MarketSymbol, ticker));
276285
}
286+
277287
if (tickerList.Count != 0)
278288
{
279289
callback(tickerList);

0 commit comments

Comments
 (0)