Class CircuitBreakers

java.lang.Object
com.quantfinlib.microstructure.CircuitBreakers

public final class CircuitBreakers extends Object
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 Classes
    Modifier and Type
    Class
    Description
    static enum 
    MWCB halt decision.
    static final class 
    The 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 enum 
    LULD per-symbol state.
    static final class 
    Market-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 Type
    Method
    Description
    static double
    luldBandPct(double referencePrice, boolean tier1, boolean widened)
    LULD band as a fraction of the reference price.
    static double
    luldLowerBand(double referencePrice, boolean tier1, boolean widened)
    Lower LULD band price.
    static double
    luldUpperBand(double referencePrice, boolean tier1, boolean widened)
    Upper LULD band price.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 marketdata convention) 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 dollars
      tier1 - true for Tier 1 symbols (S&P 500 / Russell 1000 / designated ETPs), false for Tier 2
      widened - 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.