public class OrderByOrderBook
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
OrderByOrderBook.Order
Describes single order
|
static class |
OrderByOrderBook.OrderUpdateResult
User to describe
updateOrder(long, int, long) result. |
Modifier and Type | Field and Description |
---|---|
private OrderBook |
orderBook |
private java.util.Map<java.lang.Long,OrderByOrderBook.Order> |
orders |
Constructor and Description |
---|
OrderByOrderBook() |
Modifier and Type | Method and Description |
---|---|
long |
addOrder(long id,
boolean isBid,
int price,
long size)
Add new order
|
java.util.Collection<java.lang.Long> |
getAllIds()
Get all identifiers of orders in the book
|
int |
getLastPriceOfOrder(long id)
Get current price corresponding to the order
|
OrderByOrderBook.Order |
getOrder(long id)
Get order by id
|
OrderBook |
getOrderBook()
Returns a backing order book.
|
boolean |
getSide(long id)
Get side of an order
|
boolean |
hasOrder(long id)
Check if order is in the book
|
long |
removeOrder(long id)
Remove existing order from the book
|
void |
selfTest()
Run self-check verifying order book validity.
|
OrderByOrderBook.OrderUpdateResult |
updateOrder(long id,
int price,
long size)
Update existing order
|
private final OrderBook orderBook
private java.util.Map<java.lang.Long,OrderByOrderBook.Order> orders
public OrderBook getOrderBook()
public long addOrder(long id, boolean isBid, int price, long size) throws java.lang.IllegalArgumentException
id
- unique order identifierisBid
- true for bid side, false for ask sideprice
- price of the ordersize
- size of the orderjava.lang.IllegalArgumentException
- update leads to invalid book state (crosses are considered valid state)public OrderByOrderBook.OrderUpdateResult updateOrder(long id, int price, long size) throws java.lang.IllegalArgumentException
id
- unique order identifierprice
- new price of the ordersize
- new size of the orderOrderByOrderBook.OrderUpdateResult
describing effect of this updatejava.lang.IllegalArgumentException
- update leads to invalid book state (crosses are considered
valid state)public long removeOrder(long id) throws java.lang.IllegalArgumentException
id
- unique order identifierjava.lang.IllegalArgumentException
- if order does not existpublic int getLastPriceOfOrder(long id) throws java.lang.NullPointerException
id
- unique order identifierjava.lang.NullPointerException
- if order does not existpublic boolean getSide(long id) throws java.lang.NullPointerException
id
- unique order identifierjava.lang.NullPointerException
- if order does not existpublic boolean hasOrder(long id)
id
- unique order identifierpublic OrderByOrderBook.Order getOrder(long id)
id
- unique order identifierpublic java.util.Collection<java.lang.Long> getAllIds()
public void selfTest()