Skip to main content

OrderByOrderBook

Package: velox.api.layer1.layers.utils

Type: Class

Inheritance: java.lang.Object รขโ€ โ€™ OrderByOrderBook

Descriptionโ€‹

Class designed to help with conversion from MBO to MBP data.

Nested Classesโ€‹

OrderByOrderBook.Orderโ€‹

Describes single order

OrderByOrderBook.OrderUpdateResultโ€‹

Used to describe updateOrder(long, int, long) result.

Constructorsโ€‹

OrderByOrderBookโ€‹

public OrderByOrderBook()

Methodsโ€‹

getOrderBookโ€‹

public OrderBook getOrderBook()

Returns a backing order book. Do not modify it.

Returns: Backing order book


addOrderโ€‹

public long addOrder(long id, boolean isBid, int price, long size) throws IllegalArgumentException

Add new order

Parameters:

  • id - Unique order identifier
  • isBid - True for bid side, false for ask side
  • price - Price of the order
  • size - 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 identifier
  • price - New price of the order
  • size - New size of the order

Returns: OrderByOrderBook.OrderUpdateResult describing effect of this update

Throws:

  • IllegalArgumentException - Update leads to invalid book state (crosses are considered valid state)

removeOrderโ€‹

public long removeOrder(long id) throws IllegalArgumentException

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โ€‹

public int getLastPriceOfOrder(long id) throws NullPointerException

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โ€‹

public boolean getSide(long id) throws NullPointerException

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โ€‹

public OrderByOrderBook.Order getOrder(long id)

Get order by id

Parameters:

  • id - Unique order identifier

Returns: Order information or null if it does not exist


getAllIdsโ€‹

public Collection<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).