Order Book#


Market by Price (MBP) and Market by Order (MBO) both rely on maintaining sorted lists of prices (one for each side, bid and offer).

The insert, remove and update operations all have to be efficient. To achieve this goal, it’s normal to convert floating point values (prices) to integers by dividing by the tick-size (the minimum price increment) and then use this integer for all maintenance operations.

Unfortunately, it’s not always that simple…

Some markets (crypto currencies in particular) use a very small tick-size (e.g. 1e-10) with almost no limit on the range of prices. For example, on HitBTC we have seen a minimum bid price equal to the tick-size of 1e-10 and a maximum offer equal to 1e10. The range is therefore in the order of 1e20. Unfortunately, a signed 64 bit integer (maximum value is 9e18) is not enough to capture this range and the risk of overflowing is very real.

The tick-size can change over time. This may pose a problem if the tick-size increases and limit-orders are left in the book based on the old tick-size. It is therefore possible to see updates originating with a price precision less than indicated by the tick-size.