Class TickSizeSchedule

java.lang.Object
com.quantfinlib.microstructure.TickSizeSchedule

public final class TickSizeSchedule extends Object
Price-banded tick sizes — the MiFID II / ESMA RTS 11 regime where the minimum price increment depends on the instrument's price (and liquidity band), rather than being one flat number. US equities are the degenerate single-band case ($0.01 above $1).

Two ways to build one:

  • builder() — explicit bands loaded from the venue's published table (the production path: exchanges publish these);
  • esmaStyle(int) — a generated 1-2-5 progression per price decade in the shape of the ESMA table, parameterized by liquidity band (0 = most liquid ⇒ finest ticks). Faithful in structure and magnitude, but not a certified copy of RTS 11 Annex — load the real table for compliance work.

Lookups are a binary search over primitive arrays — allocation-free and cheap enough for a quoter to call per quote update. Rounding helpers come in directional flavors because order prices must round toward passivity (buys down, sells up) to stay exchange-valid.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    Accumulates (floor price, tick) bands; floors may arrive in any order.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
     
     
    esmaStyle(int liquidityBand)
    ESMA-style generated schedule: within each price decade the bands [1,2), [2,5), [5,10) carry ticks in a 1-2-5 progression, all scaled up by one decade per liquidityBand step (0 = most liquid).
    flat(double tick)
    Single flat tick for every price (US-equity style).
    boolean
    isOnTick(double price)
    Whether a price already sits on the grid (within FP tolerance).
    double
    roundDown(double price)
    Rounds down to the grid — the passive direction for a buy order.
    double
    roundDownClamped(double price)
    roundDown(double) with the clamped tick — total over any price, for hot paths (a quoter's skewed bid can drift below the first band, and throwing inside a bus listener would kill the consumer thread; the risk gate downstream is the right place to refuse bad prices).
    double
    roundNearest(double price)
    Rounds to the nearest grid point (marks, reference prices).
    double
    roundUp(double price)
    Rounds up to the grid — the passive direction for a sell order.
    double
    roundUpClamped(double price)
    roundUp(double) with the clamped tick — see roundDownClamped(double).
    double
    tickFor(double price)
    The minimum increment in force at a price.
    double
    tickForClamped(double price)
    Like tickFor(double), but prices below the first band floor take the first band's tick instead of throwing — for engines (backtesters, quoters) that must stay total over any positive price the market or a strategy can produce.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • flat

      public static TickSizeSchedule flat(double tick)
      Single flat tick for every price (US-equity style).
    • esmaStyle

      public static TickSizeSchedule esmaStyle(int liquidityBand)
      ESMA-style generated schedule: within each price decade the bands [1,2), [2,5), [5,10) carry ticks in a 1-2-5 progression, all scaled up by one decade per liquidityBand step (0 = most liquid). Covers prices from 0.0001 to 100,000.
    • builder

      public static TickSizeSchedule.Builder builder()
    • tickForClamped

      public double tickForClamped(double price)
      Like tickFor(double), but prices below the first band floor take the first band's tick instead of throwing — for engines (backtesters, quoters) that must stay total over any positive price the market or a strategy can produce. Order-entry validation should keep using the strict tickFor(double).
    • tickFor

      public double tickFor(double price)
      The minimum increment in force at a price.
    • roundDown

      public double roundDown(double price)
      Rounds down to the grid — the passive direction for a buy order.
    • roundUp

      public double roundUp(double price)
      Rounds up to the grid — the passive direction for a sell order.
    • roundDownClamped

      public double roundDownClamped(double price)
      roundDown(double) with the clamped tick — total over any price, for hot paths (a quoter's skewed bid can drift below the first band, and throwing inside a bus listener would kill the consumer thread; the risk gate downstream is the right place to refuse bad prices).
    • roundUpClamped

      public double roundUpClamped(double price)
      roundUp(double) with the clamped tick — see roundDownClamped(double).
    • roundNearest

      public double roundNearest(double price)
      Rounds to the nearest grid point (marks, reference prices).
    • isOnTick

      public boolean isOnTick(double price)
      Whether a price already sits on the grid (within FP tolerance).
    • bandCount

      public int bandCount()