diff --git a/src/ExchangeSharp/API/Exchanges/BinanceGroup/BinanceGroupCommon.cs b/src/ExchangeSharp/API/Exchanges/BinanceGroup/BinanceGroupCommon.cs index 90612190..d875e63f 100644 --- a/src/ExchangeSharp/API/Exchanges/BinanceGroup/BinanceGroupCommon.cs +++ b/src/ExchangeSharp/API/Exchanges/BinanceGroup/BinanceGroupCommon.cs @@ -32,6 +32,11 @@ protected async Task GetWebSocketStreamUrlForSymbolsAsync(string suffix, { marketSymbols = (await GetMarketSymbolsAsync()).ToArray(); } + if (marketSymbols.Length > 400) + { + marketSymbols = marketSymbols.Take(400).ToArray(); + Logger.Warn("subscribing to the first 400 symbols"); // binance does not allow subscribing to more than 400 symbols at a time + } StringBuilder streams = new StringBuilder("/stream?streams="); for (int i = 0; i < marketSymbols.Length; i++) @@ -234,9 +239,15 @@ protected override async Task>> return tickers; } - protected override Task OnGetTickersWebSocketAsync(Action>> callback, params string[] symbols) + protected override async Task OnGetTickersWebSocketAsync(Action>> callback, params string[] symbols) { - return ConnectPublicWebSocketAsync("/stream?streams=!ticker@arr", async (_socket, msg) => + string url = null; + if (symbols == null || symbols.Length == 0) + { + url = "/stream?streams=!ticker@arr"; + } + else url = await GetWebSocketStreamUrlForSymbolsAsync("@ticker", symbols); + return await ConnectPublicWebSocketAsync(url, async (_socket, msg) => { JToken token = JToken.Parse(msg.ToStringFromUTF8()); List> tickerList = new List>(); @@ -275,11 +286,6 @@ protected override async Task OnGetTradesWebSocketAsync(Func 400) - { - marketSymbols = marketSymbols.Take(400).ToArray(); - Logger.Warn("subscribing to the first 400 symbols"); // binance does not allow subscribing to more than 400 symbols at a time - } string url = await GetWebSocketStreamUrlForSymbolsAsync("@aggTrade", marketSymbols); return await ConnectPublicWebSocketAsync(url, messageCallback: async (_socket, msg) => {