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.
  • Constructor Details

  • 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 java.lang.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:
      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.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:
      java.lang.IllegalArgumentException - update leads to invalid book state (crosses are considered valid state)
    • removeOrder

      public long removeOrder​(long id) throws java.lang.IllegalArgumentException
      Remove 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.NullPointerException
      Get 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.NullPointerException
      Get 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

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