Class TickSizeSchedule
java.lang.Object
com.quantfinlib.microstructure.TickSizeSchedule
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 ClassesModifier and TypeClassDescriptionstatic final classAccumulates (floor price, tick) bands; floors may arrive in any order. -
Method Summary
Modifier and TypeMethodDescriptionintstatic TickSizeSchedule.Builderbuilder()static TickSizeScheduleesmaStyle(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 perliquidityBandstep (0 = most liquid).static TickSizeScheduleflat(double tick) Single flat tick for every price (US-equity style).booleanisOnTick(double price) Whether a price already sits on the grid (within FP tolerance).doubleroundDown(double price) Rounds down to the grid — the passive direction for a buy order.doubleroundDownClamped(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).doubleroundNearest(double price) Rounds to the nearest grid point (marks, reference prices).doubleroundUp(double price) Rounds up to the grid — the passive direction for a sell order.doubleroundUpClamped(double price) roundUp(double)with the clamped tick — seeroundDownClamped(double).doubletickFor(double price) The minimum increment in force at a price.doubletickForClamped(double price) LiketickFor(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.
-
Method Details
-
flat
Single flat tick for every price (US-equity style). -
esmaStyle
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 perliquidityBandstep (0 = most liquid). Covers prices from 0.0001 to 100,000. -
builder
-
tickForClamped
public double tickForClamped(double price) LiketickFor(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 stricttickFor(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 — seeroundDownClamped(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()
-