Class Order

java.lang.Object
org.knowm.xchange.dto.Order
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
BitstampGenericOrder, LimitOrder, MarketOrder, StopOrder

public abstract class Order extends Object implements Serializable
Data object representing an order
See Also:
  • Constructor Details

    • Order

      public Order(Order.OrderType type, BigDecimal originalAmount, Instrument instrument, String id, Date timestamp)
      Parameters:
      type - Either BID (buying) or ASK (selling)
      originalAmount - The amount to trade
      instrument - instrument The identifier (e.g. BTC/USD)
      id - An id (usually provided by the exchange)
      timestamp - the absolute time for this order according to the exchange's server, null if not provided
    • Order

      public Order(Order.OrderType type, BigDecimal originalAmount, Instrument instrument, String id, Date timestamp, BigDecimal averagePrice, BigDecimal cumulativeAmount, BigDecimal fee, Order.OrderStatus status)
      Parameters:
      type - Either BID (buying) or ASK (selling)
      originalAmount - The amount to trade
      instrument - The identifier (e.g. BTC/USD)
      id - An id (usually provided by the exchange)
      timestamp - the absolute time for this order according to the exchange's server, null if not provided
      averagePrice - the averagePrice of fill belonging to the order
      cumulativeAmount - the amount that has been filled
      fee - the fee associated with this order
      status - the status of the order at the exchange
    • Order

      public Order(Order.OrderType type, BigDecimal originalAmount, Instrument instrument, String id, Date timestamp, BigDecimal averagePrice, BigDecimal cumulativeAmount, BigDecimal fee, Order.OrderStatus status, String userReference)
      Parameters:
      type - Either BID (buying) or ASK (selling)
      originalAmount - The amount to trade
      instrument - The identifier (e.g. BTC/USD)
      id - An id (usually provided by the exchange)
      timestamp - the absolute time for this order according to the exchange's server, null if not provided
      averagePrice - the averagePrice of fill belonging to the order
      cumulativeAmount - the amount that has been filled
      fee - the fee associated with this order
      status - the status of the order at the exchange
      userReference - a reference provided by the user to identify the order
  • Method Details

    • getFee

      public BigDecimal getFee()
      The total of the fees incurred for all transactions related to this order
      Returns:
      null if this information is not available on the order level on the given exchange in which case you will have to navigate trades which filled this order to calculate it
    • setFee

      public void setFee(BigDecimal fee)
    • getType

      public Order.OrderType getType()
      Returns:
      The type (BID or ASK)
    • getStatus

      public Order.OrderStatus getStatus()
      Returns:
      The type (PENDING_NEW, NEW, PARTIALLY_FILLED, FILLED, PENDING_CANCEL, CANCELED, PENDING_REPLACE, REPLACED, STOPPED, REJECTED or EXPIRED)
    • getOriginalAmount

      public BigDecimal getOriginalAmount()
      The amount to trade
    • getCumulativeAmount

      public BigDecimal getCumulativeAmount()
      The amount that has been filled
    • setCumulativeAmount

      public void setCumulativeAmount(BigDecimal cumulativeAmount)
    • getCumulativeCounterAmount

      public BigDecimal getCumulativeCounterAmount()
    • getRemainingAmount

      public BigDecimal getRemainingAmount()
      Returns:
      The remaining order amount
    • getAveragePrice

      public BigDecimal getAveragePrice()
      The average price of the fills in the order.
      Returns:
      null if this information is not available on the order level on the given exchange in which case you will have to navigate trades which filled this order to calculate it
    • setAveragePrice

      public void setAveragePrice(BigDecimal averagePrice)
    • 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

    • getInstrument

      public Instrument getInstrument()
      Returns:
      The instrument to be bought or sold
    • getId

      public String getId()
      Returns:
      A unique identifier (normally provided by the exchange)
    • getUserReference

      public String getUserReference()
      Returns:
      A unique identifier provided by the user on placement
    • getTimestamp

      public Date getTimestamp()
    • getOrderFlags

      public Set<Order.IOrderFlags> getOrderFlags()
    • setOrderFlags

      public void setOrderFlags(Set<Order.IOrderFlags> flags)
    • hasFlag

      public boolean hasFlag(Order.IOrderFlags flag)
    • addOrderFlag

      public void addOrderFlag(Order.IOrderFlags flag)
    • setOrderStatus

      public void setOrderStatus(Order.OrderStatus status)
    • getLeverage

      public String getLeverage()
    • setLeverage

      public void setLeverage(String leverage)
    • toString

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

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

      public boolean equals(Object obj)
      Overrides:
      equals in class Object