Package velox.api.layer1.layers.utils
Class OrderByOrderBook
java.lang.Object
velox.api.layer1.layers.utils.OrderByOrderBook
Class designed to help with conversion from MBO to MBP data.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classDescribes single orderstatic classUser to describeupdateOrder(long, int, long)result. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongaddOrder(long id, boolean isBid, int price, long size) Add new orderGet all identifiers of orders in the bookintgetLastPriceOfOrder(long id) Get current price corresponding to the ordergetOrder(long id) Get order by idReturns a backing order book.booleangetSide(long id) Get side of an orderbooleanhasOrder(long id) Check if order is in the booklongremoveOrder(long id) Remove existing order from the bookvoidselfTest()Run self-check verifying order book validity.updateOrder(long id, int price, long size) Update existing order
-
Constructor Details
-
OrderByOrderBook
public OrderByOrderBook()
-
-
Method Details
-
getOrderBook
Returns a backing order book. Do not modify it. -
addOrder
Add new order- Parameters:
id- unique order identifierisBid- true for bid side, false for ask sideprice- price of the ordersize- size of the order- Returns:
- new size at the level where order is added
- Throws:
IllegalArgumentException- update leads to invalid book state (crosses are considered valid state)
-
updateOrder
public OrderByOrderBook.OrderUpdateResult updateOrder(long id, int price, long size) throws IllegalArgumentException Update existing order- Parameters:
id- unique order identifierprice- new price of the ordersize- new size of the order- Returns:
OrderByOrderBook.OrderUpdateResultdescribing effect of this update- Throws:
IllegalArgumentException- update leads to invalid book state (crosses are considered valid state)
-
removeOrder
Remove existing order from the book- Parameters:
id- unique order identifier- Returns:
- new size on the level where order is removed
- Throws:
IllegalArgumentException- if order does not exist
-
getLastPriceOfOrder
Get current price corresponding to the order- Parameters:
id- unique order identifier- Returns:
- price of the order
- Throws:
NullPointerException- if order does not exist
-
getSide
Get side of an order- Parameters:
id- unique order identifier- Returns:
- true if bid, false if ask
- Throws:
NullPointerException- if order does not exist
-
hasOrder
public boolean hasOrder(long id) Check if order is in the book- Parameters:
id- unique order identifier- Returns:
- true if order is in the book, false otherwise
-
getOrder
Get order by id- Parameters:
id- unique order identifier- Returns:
- order information or null if it does not exist
-
getAllIds
Get all identifiers of orders in the book- Returns:
- all identifiers of orders in the book
-
selfTest
public void selfTest()Run self-check verifying order book validity. Detects some common issues (but not all).
-