Class Trade

java.lang.Object
org.knowm.xchange.dto.marketdata.Trade
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
UserTrade

public class Trade extends Object implements Serializable
Data object representing a Trade
See Also:
  • Field Details

    • type

      protected final Order.OrderType type
      Did this trade result from the execution of a bid or a ask?
    • originalAmount

      protected final BigDecimal originalAmount
      Amount that was traded
    • instrument

      protected final Instrument instrument
      The instrument
    • price

      protected final BigDecimal price
      The price
    • timestamp

      protected final Date timestamp
      The timestamp of the trade according to the exchange's server, null if not provided
    • id

      protected final String id
      The trade id
    • makerOrderId

      protected final String makerOrderId
    • takerOrderId

      protected final String takerOrderId
  • Constructor Details

    • Trade

      public Trade(Order.OrderType type, BigDecimal originalAmount, Instrument instrument, BigDecimal price, Date timestamp, String id, String makerOrderId, String takerOrderId)
      This constructor is called to create a public Trade object in MarketDataService.getTrades(org.knowm.xchange.currency.CurrencyPair, Object...) implementations) since it's missing the orderId and fee parameters.
      Parameters:
      type - The trade type (BID side or ASK side)
      originalAmount - The depth of this trade
      price - The price (either the bid or the ask)
      timestamp - The timestamp of the trade according to the exchange's server, null if not provided
      id - The id of the trade
      makerOrderId - The orderId of the maker in the trade
      takerOrderId - The orderId of the taker in the trade
  • Method Details

    • getType

      public Order.OrderType getType()
    • getOriginalAmount

      public BigDecimal getOriginalAmount()
    • getInstrument

      public Instrument getInstrument()
    • getCurrencyPair

      @Deprecated public CurrencyPair getCurrencyPair()
      Deprecated.
      CurrencyPair is a subtype of Instrument - this method will throw an exception if the order was for a derivative

      use getInstrument() instead

    • getPrice

      public BigDecimal getPrice()
    • getTimestamp

      public Date getTimestamp()
    • getId

      public String getId()
    • getMakerOrderId

      public String getMakerOrderId()
    • getTakerOrderId

      public String getTakerOrderId()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object