Class BinanceStreamingTradeService

java.lang.Object
info.bitrich.xchangestream.binance.BinanceStreamingTradeService
All Implemented Interfaces:
StreamingTradeService

public class BinanceStreamingTradeService extends Object implements StreamingTradeService
  • Constructor Details

  • Method Details

    • getRawExecutionReports

      public io.reactivex.rxjava3.core.Observable<ExecutionReportBinanceUserTransaction> getRawExecutionReports()
    • getRawOrderTradeUpdate

      public io.reactivex.rxjava3.core.Observable<OrderTradeUpdateBinanceWebSocketTransaction> getRawOrderTradeUpdate()
    • getRawTradeLite

      public io.reactivex.rxjava3.core.Observable<TradeLiteBinanceWebsocketTransaction> getRawTradeLite()
    • getRawPositionChanges

      public io.reactivex.rxjava3.core.Observable<AccountUpdateBinanceWebSocketTransaction> getRawPositionChanges(boolean isFuture)
    • getOrderChanges

      public io.reactivex.rxjava3.core.Observable<Order> getOrderChanges(boolean isFuture)
    • getOrderChanges

      public io.reactivex.rxjava3.core.Observable<Order> getOrderChanges(CurrencyPair currencyPair, Object... args)
      Description copied from interface: StreamingTradeService
      Get the changes of order state for the logged-in user.

      Warning: there are currently no guarantees that messages will arrive in order, that messages will not be skipped, or that any initial state message will be sent on connection. Most exchanges have a recommended approach for managing this, involving timestamps, sequence numbers and a separate REST API for re-sync when inconsistencies appear. You should implement these approaches, if required, by combining calls to this method with TradeService.getOpenOrders().

      Emits NotConnectedException When not connected to the WebSocket API.

      Immediately throws ExchangeSecurityException if called without authentication details

      Specified by:
      getOrderChanges in interface StreamingTradeService
      Parameters:
      currencyPair - Currency pair of the order changes.
      Returns:
      Observable that emits Order when exchange sends the update.
    • getOrderChanges

      public io.reactivex.rxjava3.core.Observable<Order> getOrderChanges(Instrument instrument, Object... args)
      Specified by:
      getOrderChanges in interface StreamingTradeService
    • getUserTrades

      public io.reactivex.rxjava3.core.Observable<UserTrade> getUserTrades(CurrencyPair currencyPair, Object... args)
      Description copied from interface: StreamingTradeService
      Gets authenticated trades for the logged-in user.

      Warning: there are currently no guarantees that messages will arrive in order, that messages will not be skipped, or that any initial state message will be sent on connection. Most exchanges have a recommended approach for managing this, involving timestamps, sequence numbers and a separate REST API for re-sync when inconsistencies appear. You should implement these approaches, if required, by combining calls to this method with TradeService.getTradeHistory(org.knowm.xchange.service.trade.params.TradeHistoryParams)

      Emits NotConnectedException When not connected to the WebSocket API.

      Immediately throws ExchangeSecurityException if called without authentication details

      Specified by:
      getUserTrades in interface StreamingTradeService
      Parameters:
      currencyPair - Currency pair for which to get trades.
      Returns:
      Observable that emits UserTrade when exchange sends the update.
    • getUserTrades

      public io.reactivex.rxjava3.core.Observable<UserTrade> getUserTrades(Instrument instrument, Object... args)
      Specified by:
      getUserTrades in interface StreamingTradeService
    • getUserTrades

      public io.reactivex.rxjava3.core.Observable<UserTrade> getUserTrades(boolean isFuture)
    • getPositionChanges

      public io.reactivex.rxjava3.core.Observable<OpenPosition> getPositionChanges(Instrument instrument)
      Specified by:
      getPositionChanges in interface StreamingTradeService
    • placeMarketOrder

      public io.reactivex.rxjava3.core.Single<Integer> placeMarketOrder(MarketOrder order, Object... args)
      Description copied from interface: StreamingTradeService
      Places a market order on the exchange. A market order is an order to buy or sell a financial instrument immediately at the best available current price. Specific exchanges may require additional optional parameters to process the market order.
      Specified by:
      placeMarketOrder in interface StreamingTradeService
      Parameters:
      order - The details of the market order, including the instrument, amount, and side (buy/sell).
      args - Optional additional arguments that may be required by specific exchanges.
      Returns:
      A Single that emits the operation result code, typically 0 for success.
    • placeLimitOrder

      public io.reactivex.rxjava3.core.Single<Integer> placeLimitOrder(LimitOrder order, Object... args)
      Description copied from interface: StreamingTradeService
      Places a limit order on the exchange. A limit order specifies the price at which the user wants to buy or sell a financial instrument, potentially with additional optional parameters.
      Specified by:
      placeLimitOrder in interface StreamingTradeService
      Parameters:
      order - The details of the limit order, including instrument, price, volume, and side (buy/sell).
      args - Optional additional arguments that may be required by specific exchanges.
      Returns:
      A Single that emits the operation result code, typically 0 for success.
    • placeOrder

      public io.reactivex.rxjava3.core.Single<Integer> placeOrder(Order order)
    • changeOrder

      public io.reactivex.rxjava3.core.Single<Integer> changeOrder(LimitOrder limitOrder, Object... args)
      Description copied from interface: StreamingTradeService
      Modifies an existing limit order on the exchange. This can include changes to the price, volume, or other adjustable parameters of the order, depending on the exchange's specific functionality and constraints.
      Specified by:
      changeOrder in interface StreamingTradeService
      Parameters:
      limitOrder - The limit order to be modified, including the updated details such as price or/and volume.
      args - Optional additional arguments that may be required by specific exchanges.
      Returns:
      A Single that emits the operation result code, typically 0 for success.
    • cancelOrder

      public io.reactivex.rxjava3.core.Single<Integer> cancelOrder(CancelOrderParams orderParams, Object... args)
      Description copied from interface: StreamingTradeService
      Cancels an existing order on the exchange. The operation requires specific parameters describing the order to be canceled, such as order ID or user reference ID.
      Specified by:
      cancelOrder in interface StreamingTradeService
      Parameters:
      orderParams - An object implementing CancelOrderParams that contains order ID or user reference ID.
      args - Optional additional arguments that may be required by specific exchanges.
      Returns:
      A Single that emits the operation result code, typically 0 for success.
    • openSubscriptions

      public void openSubscriptions()
      Registers subsriptions with the streaming service for the given products.