Class BinanceStreamingExchange

java.lang.Object
org.knowm.xchange.BaseExchange
org.knowm.xchange.binance.BinanceExchange
info.bitrich.xchangestream.binance.BinanceStreamingExchange
All Implemented Interfaces:
StreamingExchange, Exchange
Direct Known Subclasses:
BinanceFutureStreamingExchange, BinanceUsStreamingExchange

public class BinanceStreamingExchange extends BinanceExchange implements StreamingExchange
  • Field Details

  • Constructor Details

    • BinanceStreamingExchange

      public BinanceStreamingExchange()
  • Method Details

    • initServices

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

      public io.reactivex.rxjava3.core.Completable connect(KlineSubscription klineSubscription, ProductSubscription... args)
    • connect

      public io.reactivex.rxjava3.core.Completable connect(ProductSubscription... args)
      Binance streaming API expects connections to multiple channels to be defined at connection time. To define the channels for this connection pass a `ProductSubscription` in at connection time.
      Specified by:
      connect in interface StreamingExchange
      Parameters:
      args - A single `ProductSubscription` to define the subscriptions required to be available during this connection.
      Returns:
      A completable which fulfils once connection is complete.
    • 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.
    • 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.
    • 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
    • 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
    • getStreamingMarketDataService

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

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

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

      protected BinanceStreamingService createStreamingService(ProductSubscription subscription, KlineSubscription klineSubscription)
    • getStreamingBaseUri

      protected String getStreamingBaseUri()
    • buildSubscriptionStreams

      public String buildSubscriptionStreams(ProductSubscription subscription)
    • 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
    • enableLiveSubscription

      public void enableLiveSubscription()
    • disableLiveSubscription

      public void disableLiveSubscription()
    • setChannelInactiveHandler

      public void setChannelInactiveHandler(WebSocketClientHandler.WebSocketMessageHandler channelInactiveHandler)
      Enables the user to listen on channel inactive events and react appropriately.
      Parameters:
      channelInactiveHandler - a WebSocketMessageHandler instance.