Class OrderByOrderBook

java.lang.Object
velox.api.layer1.layers.utils.OrderByOrderBook

public class OrderByOrderBook extends Object
Class designed to help with conversion from MBO to MBP data.
  • Constructor Details

    • OrderByOrderBook

      public OrderByOrderBook()
  • Method Details

    • getOrderBook

      public OrderBook getOrderBook()
      Returns a backing order book. Do not modify it.
    • 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).