knowm / XChange

XChange is a Java library providing a streamlined API for interacting with 60+ Bitcoin and Altcoin exchanges providing a consistent interface for trading and accessing market data.
http://knowm.org/open-source/xchange/
MIT License
3.82k stars 1.93k forks source link

Kraken order book stream - subscribe to multiple currency pairs by one messge #3882

Open davidjirovec opened 3 years ago

davidjirovec commented 3 years ago

Current implementation supports only one currency pair subscribe per one sent message via websocket. In case of subscribing to many currency pairs, Kraken ws soon hits rate limits.

Kraken ws supports subscribe to multiple channels by one message https://docs.kraken.com/websockets/#message-subscribe

It would be nice to be able to use this ability. I guess info.bitrich.xchangestream.core.StreamingExchange#connect with ProductSubscription argument is good place to implement this.

earce commented 3 years ago

We currently have some outstanding work to rate limit message passing for subscription to currency pairs.

davidjirovec commented 3 years ago

I've actually implemented my own rate limiting. I've wrapped websocket sendMessage() by aspectj and Guava rate limiter. Not nice but working :) Problem is it takes a long time to be able to send all subscription messages I need.

Sending just one message to subscribe all required channels would be ultimate solution.

earce commented 3 years ago

We can copy CoinbasePro's pattern for this as it handles this, feel free to open a PR for this