Class RippleTradeService

All Implemented Interfaces:
BaseService, TradeService

public class RippleTradeService extends RippleTradeServiceRaw implements TradeService
  • Constructor Details

    • RippleTradeService

      public RippleTradeService(RippleExchange exchange)
  • Method Details

    • getOpenOrders

      public OpenOrders getOpenOrders() throws IOException
      The additional data map of an order will be populated with
      invalid @link
      RippleExchange.DATA_BASE_COUNTERPARTY
      if the base currency is not XRP, similarly if the counter currency is not XRP then
      invalid @link
      RippleExchange.DATA_COUNTER_COUNTERPARTY
      will be populated.
      Specified by:
      getOpenOrders in interface TradeService
      Returns:
      the open orders, null if some sort of error occurred. Implementers should log the error.
      Throws:
      IOException - - Indication that a networking error occurred while fetching JSON data
    • getOpenOrders

      public OpenOrders getOpenOrders(OpenOrdersParams params) throws IOException
      Description copied from interface: TradeService
      Gets the open orders
      Specified by:
      getOpenOrders in interface TradeService
      Parameters:
      params - The parameters describing the filter. Note that OpenOrdersParams is an empty interface. Exchanges should implement its own params object. Params should be create with TradeService.createOpenOrdersParams().
      Returns:
      the open orders, null if some sort of error occurred. Implementers should log the error.
      Throws:
      IOException - - Indication that a networking error occurred while fetching JSON data
    • placeLimitOrder

      public String placeLimitOrder(LimitOrder order) throws IOException
      Description copied from interface: TradeService
      Place a limit order

      If your orders amount or limit price does to meet the restrictions dictated by InstrumentMetaData then the exchange will reject your order. Use OrderValuesHelper to validate and / or adjust those values while you'r building an order.

      Specified by:
      placeLimitOrder in interface TradeService
      Parameters:
      order - this should be a RippleLimitOrder object with the base and counter counterparties populated for any currency other than XRP.
      Returns:
      the order ID
      Throws:
      IOException - - Indication that a networking error occurred while fetching JSON data
      See Also:
    • cancelOrder

      public boolean cancelOrder(String orderId) throws IOException
      Description copied from interface: TradeService
      cancels order with matching orderId (conveniance method, typical just delegate to cancelOrder(CancelOrderByIdParams))
      Specified by:
      cancelOrder in interface TradeService
      Returns:
      true if order was successfully cancelled, false otherwise.
      Throws:
      IOException - - Indication that a networking error occurred while fetching JSON data
    • cancelOrder

      public boolean cancelOrder(CancelOrderParams orderParams) throws IOException
      Description copied from interface: TradeService
      cancels order with matching orderParams
      Specified by:
      cancelOrder in interface TradeService
      Returns:
      true if order was successfully cancelled, false otherwise.
      Throws:
      IOException - - Indication that a networking error occurred while fetching JSON data
    • getTradeHistory

      public UserTrades getTradeHistory(TradeHistoryParams params) throws IOException
      Ripple trade history is a request intensive process. The REST API does not provide a simple single trade history query. Trades are retrieved by querying account notifications and for those of type order details of the hash are then queried. These order detail queries could be order entry, cancel or execution, it is not possible to tell from the notification. Therefore if an account is entering many orders but executing few of them, this trade history query will result in many API calls without returning any trade history. In order to reduce the time and resources used in these repeated calls In order to reduce the number of API calls a number of different methods can be used:
      Specified by:
      getTradeHistory in interface TradeService
      Parameters:
      params - Can optionally implement , , , , TradeHistoryParamPaging, , TradeHistoryParamsTimeSpan. All other TradeHistoryParams types will be ignored.
      Returns:
      UserTrades as returned by the exchange API
      Throws:
      IOException - - Indication that a networking error occurred while fetching JSON data
      See Also:
    • createTradeHistoryParams

      public RippleTradeHistoryParams createTradeHistoryParams()
      Description copied from interface: TradeService
      Create TradeHistoryParams object specific to this exchange. Object created by this method may be used to discover supported and required TradeService.getTradeHistory(TradeHistoryParams) parameters and should be passed only to the method in the same class as the createTradeHistoryParams that created the object.
      Specified by:
      createTradeHistoryParams in interface TradeService
    • createOpenOrdersParams

      public OpenOrdersParams createOpenOrdersParams()
      Description copied from interface: TradeService
      Create OpenOrdersParams object specific to this exchange. Object created by this method may be used to discover supported and required TradeService.getOpenOrders(OpenOrdersParams) parameters and should be passed only to the method in the same class as the createOpenOrdersParams that created the object.
      Specified by:
      createOpenOrdersParams in interface TradeService