Package velox.api.layer1.layers.utils
Class OrderByOrderBook
java.lang.Object
velox.api.layer1.layers.utils.OrderByOrderBook
public class OrderByOrderBook
extends java.lang.Object
Class designed to help with conversion from MBO to MBP data.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classOrderByOrderBook.OrderDescribes single orderstatic classOrderByOrderBook.OrderUpdateResultUser to describeupdateOrder(long, int, long)result. -
Constructor Summary
Constructors Constructor Description OrderByOrderBook() -
Method Summary
Modifier and Type Method Description longaddOrder(long id, boolean isBid, int price, long size)Add new orderjava.util.Collection<java.lang.Long>getAllIds()Get all identifiers of orders in the bookintgetLastPriceOfOrder(long id)Get current price corresponding to the orderOrderByOrderBook.OrdergetOrder(long id)Get order by idOrderBookgetOrderBook()Returns 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.OrderByOrderBook.OrderUpdateResultupdateOrder(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
public long addOrder(long id, boolean isBid, int price, long size) throws java.lang.IllegalArgumentExceptionAdd 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:
java.lang.IllegalArgumentException- update leads to invalid book state (crosses are considered valid state)
-
updateOrder
public OrderByOrderBook.OrderUpdateResult updateOrder(long id, int price, long size) throws java.lang.IllegalArgumentExceptionUpdate 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:
java.lang.IllegalArgumentException- update leads to invalid book state (crosses are considered valid state)
-
removeOrder
public long removeOrder(long id) throws java.lang.IllegalArgumentExceptionRemove existing order from the book- Parameters:
id- unique order identifier- Returns:
- new size on the level where order is removed
- Throws:
java.lang.IllegalArgumentException- if order does not exist
-
getLastPriceOfOrder
public int getLastPriceOfOrder(long id) throws java.lang.NullPointerExceptionGet current price corresponding to the order- Parameters:
id- unique order identifier- Returns:
- price of the order
- Throws:
java.lang.NullPointerException- if order does not exist
-
getSide
public boolean getSide(long id) throws java.lang.NullPointerExceptionGet side of an order- Parameters:
id- unique order identifier- Returns:
- true if bid, false if ask
- Throws:
java.lang.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
public java.util.Collection<java.lang.Long> 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).
-