binance-java-api
binance-java-api copied to clipboard
Problem with multiple websockets
I am trying to solve following isse. The code below will print out just 4-6 symbols but should print every available symbol. Is there any limitation to handlers count?
BinanceApiRestClient restClient = BinanceApiClientFactory.newInstance().newRestClient();
BinanceApiWebSocketClient client = BinanceApiClientFactory.newInstance().newWebSocketClient();
List<TickerPrice> tickets = restClient.getAllPrices().stream().filter(t -> t.getSymbol().contains("BTC")).collect(Collectors.toList());
tickets.forEach(t -> client.onCandlestickEvent(t.getSymbol().toLowerCase(), CandlestickInterval.ONE_MINUTE, response -> System.out.println(response)));
Result:
CandlestickEvent[eventType=kline,eventTime=1517260861554,symbol=BCCBTC,openTime=1517260860000,open=0.14726800,high=0.14726800,low=0.14726800,close=0.14726800,volume=0.06700000,closeTime=1517260919999,intervalId=1m,firstTradeId=4512726,lastTradeId=4512726,quoteAssetVolume=0.00986695,numberOfTrades=1,takerBuyBaseAssetVolume=0.06700000,takerBuyQuoteAssetVolume=0.00986695,isBarFinal=false]
CandlestickEvent[eventType=kline,eventTime=1517260863205,symbol=NEOBTC,openTime=1517260860000,open=0.01442600,high=0.01442900,low=0.01442600,close=0.01442900,volume=44.49000000,closeTime=1517260919999,intervalId=1m,firstTradeId=7270368,lastTradeId=7270371,quoteAssetVolume=0.64186422,numberOfTrades=4,takerBuyBaseAssetVolume=27.33000000,takerBuyQuoteAssetVolume=0.39426258,isBarFinal=false]
CandlestickEvent[eventType=kline,eventTime=1517260862695,symbol=LTCBTC,openTime=1517260860000,open=0.01606700,high=0.01606700,low=0.01606700,close=0.01606700,volume=0.20000000,closeTime=1517260919999,intervalId=1m,firstTradeId=5914050,lastTradeId=5914050,quoteAssetVolume=0.00321340,numberOfTrades=1,takerBuyBaseAssetVolume=0.20000000,takerBuyQuoteAssetVolume=0.00321340,isBarFinal=false]
CandlestickEvent[eventType=kline,eventTime=1517260862316,symbol=ETHBTC,openTime=1517260860000,open=0.10377000,high=0.10383400,low=0.10374100,close=0.10383400,volume=1.24700000,closeTime=1517260919999,intervalId=1m,firstTradeId=27468040,lastTradeId=27468044,quoteAssetVolume=0.12947879,numberOfTrades=5,takerBuyBaseAssetVolume=1.22300000,takerBuyQuoteAssetVolume=0.12698898,isBarFinal=false]
CandlestickEvent[eventType=kline,eventTime=1517260864456,symbol=ETHBTC,openTime=1517260860000,open=0.10377000,high=0.10383400,low=0.10374100,close=0.10383400,volume=1.63900000,closeTime=1517260919999,intervalId=1m,firstTradeId=27468040,lastTradeId=27468045,quoteAssetVolume=0.17018171,numberOfTrades=6,takerBuyBaseAssetVolume=1.61500000,takerBuyQuoteAssetVolume=0.16769190,isBarFinal=false]
CandlestickEvent[eventType=kline,eventTime=1517260864000,symbol=NEOBTC,openTime=1517260860000,open=0.01442600,high=0.01443000,low=0.01442600,close=0.01442900,volume=71.31000000,closeTime=1517260919999,intervalId=1m,firstTradeId=7270368,lastTradeId=7270373,quoteAssetVolume=1.02885006,numberOfTrades=6,takerBuyBaseAssetVolume=27.39000000,takerBuyQuoteAssetVolume=0.39512838,isBarFinal=false]
CandlestickEvent[eventType=kline,eventTime=1517260865202,symbol=LTCBTC,openTime=1517260860000,open=0.01606700,high=0.01606700,low=0.01606600,close=0.01606600,volume=0.42000000,closeTime=1517260919999,intervalId=1m,firstTradeId=5914050,lastTradeId=5914051,quoteAssetVolume=0.00674792,numberOfTrades=2,takerBuyBaseAssetVolume=0.42000000,takerBuyQuoteAsset
UPDATE: Yes, it is 5 streams, more is ignored. I cannot find any limitation in API or in your code. Is anybody experiencing the same issue?
The workaround of course is to create more BinanceApiWebSocketClient
each must handle just 5 symbols, not more. However I really wonder where the catch is. Binance seems to not return no error while subscribing to 6th...
I'm missing this too. Is there really no other way to subscribe to all pairs on exchange?
I just tested it. And it seems that I get all available pairs. All together 256 pairs currently. Can be that is fixed now?
@jurepetrovic Maybe there was some change on the server side. In the code, there was no sign of limiting. Hmm...