Package org.knowm.xchange.dto.marketdata
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:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description OrderBook(Date timeStamp, List<LimitOrder> asks, List<LimitOrder> bids)
ConstructorOrderBook(Date timeStamp, List<LimitOrder> asks, List<LimitOrder> bids, boolean sort)
ConstructorOrderBook(Date timeStamp, Stream<LimitOrder> asks, Stream<LimitOrder> bids)
ConstructorOrderBook(Date timeStamp, Stream<LimitOrder> asks, Stream<LimitOrder> bids, boolean sort)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
List<LimitOrder>
getAsks()
List<LimitOrder>
getBids()
List<LimitOrder>
getOrders(Order.OrderType type)
Date
getTimeStamp()
int
hashCode()
boolean
ordersEqual(OrderBook ob)
Identical toequals
method except that this ignores different timestamps.String
toString()
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.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.
-
-
-
Constructor Detail
-
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 providedasks
- The ASK ordersbids
- 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 providedasks
- The ASK ordersbids
- The BID orderssort
- 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 providedasks
- The ASK ordersbids
- 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 providedasks
- The ASK ordersbids
- The BID orderssort
- True if the asks and bids need to be sorted
-
-
Method Detail
-
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
-
ordersEqual
public boolean ordersEqual(OrderBook ob)
Identical toequals
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:
-
-