Class OrderBook

java.lang.Object
org.knowm.xchange.dto.marketdata.OrderBook
All Implemented Interfaces:
Serializable

public final class OrderBook extends Object implements Serializable
DTO representing the exchange order book
See Also:
  • Constructor Details

    • OrderBook

      public OrderBook(Date timeStamp, List<LimitOrder> asks, List<LimitOrder> bids)
      Constructor
      Parameters:
      timeStamp - - the timestamp of the orderbook according to the exchange's server, null if not provided
      asks - The ASK orders
      bids - The BID orders
    • OrderBook

      public OrderBook(Date timeStamp, List<LimitOrder> asks, List<LimitOrder> bids, boolean sort)
      Constructor
      Parameters:
      timeStamp - - the timestamp of the orderbook according to the exchange's server, null if not provided
      asks - The ASK orders
      bids - The BID orders
      sort - True if the asks and bids need to be sorted
    • OrderBook

      public OrderBook(Date timeStamp, Stream<LimitOrder> asks, Stream<LimitOrder> bids)
      Constructor
      Parameters:
      timeStamp - - the timestamp of the orderbook according to the exchange's server, null if not provided
      asks - The ASK orders
      bids - The BID orders
    • OrderBook

      public OrderBook(Date timeStamp, Stream<LimitOrder> asks, Stream<LimitOrder> bids, boolean sort)
      Constructor
      Parameters:
      timeStamp - - the timestamp of the orderbook according to the exchange's server, null if not provided
      asks - The ASK orders
      bids - The BID orders
      sort - True if the asks and bids need to be sorted
  • Method Details

    • getTimeStamp

      public Date getTimeStamp()
    • getAsks

      public List<LimitOrder> getAsks()
    • getBids

      public List<LimitOrder> getBids()
    • getOrders

      public List<LimitOrder> getOrders(Order.OrderType type)
    • update

      public void update(LimitOrder limitOrder)
      Given a new LimitOrder, it will replace a matching limit order in the orderbook if one is found, or add the new LimitOrder if one is not. timeStamp will be updated if the new timestamp is non-null and in the future.
      Parameters:
      limitOrder - the new LimitOrder
    • update

      public void update(OrderBookUpdate orderBookUpdate)
      Given an OrderBookUpdate, it will replace a matching limit order in the orderbook if one is found, or add a new if one is not. timeStamp will be updated if the new timestamp is non-null and in the future.
      Parameters:
      orderBookUpdate - the new OrderBookUpdate
    • hashCode

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

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

      public boolean ordersEqual(OrderBook ob)
      Identical to equals method except that this ignores different timestamps. In other words, this version of equals returns true if the order internal to the OrderBooks are equal but their timestamps are unequal. It returns false if any order between the two are different.
      Parameters:
      ob -
      Returns:
    • toString

      public String toString()
      Overrides:
      toString in class Object