Class CircuitBreakers
java.lang.Object
com.quantfinlib.microstructure.CircuitBreakers
US-equities trading safeguards, styled after the SEC's Limit Up-Limit Down
plan and the market-wide circuit-breaker rule (not certified
implementations — the regulatory texts govern):
- LULD price bands (
luldBandPct(double, boolean, boolean),CircuitBreakers.Luld) — per-symbol bands around a reference price; quoting at a band edge enters a limit state, and a limit state that persists 15 seconds becomes a 5-minute trading pause; - Market-wide circuit breakers (
CircuitBreakers.MarketWide) — S&P 500 declines of 7% / 13% halt the market for 15 minutes (each at most once per day, and not after 15:25), and 20% halts for the day.
The CircuitBreakers.Luld state machine is primitives-only and allocation-free:
drive it from the NBBO callback.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumMWCB halt decision.static final classThe LULD limit-state machine for one symbol: enters a limit state when the inside quote pins a band edge, converts to a 5-minute pause when the limit state persists 15 seconds, and exits the pause after it elapses.static enumLULD per-symbol state.static final classMarket-wide circuit-breaker day state: feed it the S&P 500 decline from the prior close and the time of day; it applies the once-per-day and not-after-15:25 rules for Levels 1 and 2. -
Method Summary
Modifier and TypeMethodDescriptionstatic doubleluldBandPct(double referencePrice, boolean tier1, boolean widened) LULD band as a fraction of the reference price.static doubleluldLowerBand(double referencePrice, boolean tier1, boolean widened) Lower LULD band price.static doubleluldUpperBand(double referencePrice, boolean tier1, boolean widened) Upper LULD band price.
-
Method Details
-
luldBandPct
public static double luldBandPct(double referencePrice, boolean tier1, boolean widened) LULD band as a fraction of the reference price.Units: dollars, not ticks. The tier thresholds ($3.00, $0.75, $0.15) are dollar amounts from the plan, so a price fed in 0.0001-tick ints (the
marketdataconvention) lands every symbol in the wrong tier — convert at the seam (tick * 1e-4) first.- Parameters:
referencePrice- the LULD reference (5-minute average price), in dollarstier1- true for Tier 1 symbols (S&P 500 / Russell 1000 / designated ETPs), false for Tier 2widened- true in the widened-band windows (the plan doubles bands near the open and close for most groups)
-
luldLowerBand
public static double luldLowerBand(double referencePrice, boolean tier1, boolean widened) Lower LULD band price. -
luldUpperBand
public static double luldUpperBand(double referencePrice, boolean tier1, boolean widened) Upper LULD band price.
-