Class KrakenStreamingExchange

java.lang.Object
org.knowm.xchange.BaseExchange
org.knowm.xchange.kraken.KrakenExchange
info.bitrich.xchangestream.kraken.KrakenStreamingExchange
All Implemented Interfaces:
StreamingExchange, Exchange

public class KrakenStreamingExchange extends KrakenExchange implements StreamingExchange
Author:
makarid
  • Constructor Details

    • KrakenStreamingExchange

      public KrakenStreamingExchange()
  • Method Details

    • pickUri

      public static String pickUri(boolean isPrivate, boolean useBeta)
    • initServices

      protected void initServices()
      Overrides:
      initServices in class KrakenExchange
    • connect

      public io.reactivex.rxjava3.core.Completable connect(ProductSubscription... args)
      Description copied from interface: StreamingExchange
      Connects to the WebSocket API of the exchange.
      Specified by:
      connect in interface StreamingExchange
      Parameters:
      args - Product subscription is used only in certain exchanges where you need to specify subscriptions during the connect phase.
      Returns:
      Completable that completes upon successful connection.
    • disconnect

      public io.reactivex.rxjava3.core.Completable disconnect()
      Description copied from interface: StreamingExchange
      Disconnect from the WebSocket API.
      Specified by:
      disconnect in interface StreamingExchange
      Returns:
      Completable that completes upon successful disconnect.
    • isAlive

      public boolean isAlive()
      Description copied from interface: StreamingExchange
      Checks whether connection to the exchange is alive.
      Specified by:
      isAlive in interface StreamingExchange
      Returns:
      true if connection is open, otherwise false.
    • connectionSuccess

      public io.reactivex.rxjava3.core.Observable<Object> connectionSuccess()
      Description copied from interface: StreamingExchange
      Observable for connection success event. When this happens, it usually indicates that the server or the network is down.
      Specified by:
      connectionSuccess in interface StreamingExchange
      Returns:
      Observable
    • disconnectObservable

      public io.reactivex.rxjava3.core.Observable<Object> disconnectObservable()
      Description copied from interface: StreamingExchange
      Observable for disconnection event.
      Specified by:
      disconnectObservable in interface StreamingExchange
      Returns:
      Observable
    • reconnectFailure

      public io.reactivex.rxjava3.core.Observable<Throwable> reconnectFailure()
      Description copied from interface: StreamingExchange
      Observable for reconnection failure event. When this happens, it usually indicates that the server or the network is down.
      Specified by:
      reconnectFailure in interface StreamingExchange
      Returns:
      Observable with the exception during reconnection.
    • connectionStateObservable

      public io.reactivex.rxjava3.core.Observable<ConnectionStateModel.State> connectionStateObservable()
      Description copied from interface: StreamingExchange
      Observable for connectionState. designed to replaces connectionSuccess reconnectFailure disconnectObservable
      Specified by:
      connectionStateObservable in interface StreamingExchange
      Returns:
      Observable
    • privateConnectionSuccess

      public io.reactivex.rxjava3.core.Observable<Object> privateConnectionSuccess()
    • privateReconnectFailure

      public io.reactivex.rxjava3.core.Observable<Throwable> privateReconnectFailure()
    • privateConnectionStateObservable

      public io.reactivex.rxjava3.core.Observable<ConnectionStateModel.State> privateConnectionStateObservable()
    • privateDisconnectObservable

      public io.reactivex.rxjava3.core.Observable<Object> privateDisconnectObservable()
    • getDefaultExchangeSpecification

      public ExchangeSpecification getDefaultExchangeSpecification()
      Specified by:
      getDefaultExchangeSpecification in interface Exchange
      Overrides:
      getDefaultExchangeSpecification in class KrakenExchange
      Returns:
      A default ExchangeSpecification to use during the creation process if one is not supplied
    • getStreamingMarketDataService

      public StreamingMarketDataService getStreamingMarketDataService()
      Description copied from interface: StreamingExchange
      Returns service that can be used to access streaming market data.
      Specified by:
      getStreamingMarketDataService in interface StreamingExchange
    • getStreamingTradeService

      public StreamingTradeService getStreamingTradeService()
      Description copied from interface: StreamingExchange
      Returns service that can be used to access streaming trade data.
      Specified by:
      getStreamingTradeService in interface StreamingExchange
    • useCompressedMessages

      public void useCompressedMessages(boolean compressedMessages)
      Description copied from interface: StreamingExchange
      Set whether or not to enable compression handler.
      Specified by:
      useCompressedMessages in interface StreamingExchange
      Parameters:
      compressedMessages - Defaults to false
    • authData

      public KrakenWebsocketToken authData(KrakenAccountServiceRaw accountServiceRaw)
      Gets a WebSocketToken following https://support.kraken.com/hc/en-us/articles/360034664311-How-to-subscribe-to-the-Kraken-WebSocket-private-feeds

      Token requests should be made before any Websocket reconnection to avoid cases where the token has become invalid due to issues on the Kraken side.

      From Kraken support:

      In theory WebSocket authentication tokens can last indefinitely, but in reality they do sometimes expire causing an invalid session error. As an example, during a recent WebSocket API upgrade, many authentication tokens became invalid (for no apparent reason to the token owners), causing unexpected invalid session errors upon reconnecting/resubscribing after the upgrade.

      Parameters:
      accountServiceRaw - account service to query new token against
      Returns:
      token retrieved
    • resubscribeChannels

      public void resubscribeChannels()
      Specified by:
      resubscribeChannels in interface StreamingExchange
    • getSystemStatusChanges

      public io.reactivex.rxjava3.core.Observable<KrakenSystemStatus> getSystemStatusChanges()
    • getPublicSubscriptionStatusChanges

      public io.reactivex.rxjava3.core.Observable<KrakenSubscriptionStatusMessage> getPublicSubscriptionStatusChanges()
    • getPrivateSubscriptionStatusChanges

      public io.reactivex.rxjava3.core.Observable<KrakenSubscriptionStatusMessage> getPrivateSubscriptionStatusChanges()