Record Class BenchmarkExecutor.MarketState

java.lang.Object
java.lang.Record
com.quantfinlib.execution.BenchmarkExecutor.MarketState
Record Components:
mid - current mid (for reference/markout)
spread - bid/ask spread in price units (cost)
volatility - normalized vol-regime signal, ~0..1
displayedDepth - size available to take now (liquidity cap)
expectedVolumeFractionElapsed - VWAP curve: fraction of the day's volume expected to have traded by now
alpha - normalized expected-move signal in [-1, 1] (+ = up)
impactBps - estimated impact of a full child in bps (MarketImpactModel / ml.MarketImpactPredictor output); damps aggression alongside the spread — trading into your own impact is a cost like crossing one
Enclosing class:
BenchmarkExecutor

public static record BenchmarkExecutor.MarketState(double mid, double spread, double volatility, double displayedDepth, double expectedVolumeFractionElapsed, double alpha, double impactBps) extends Record
A snapshot of the real-time inputs a benchmark algo evaluates. All fields are optional in the sense that a neutral value disables that input: spread=0, volatility=0, alpha=0, displayedDepth=+∞ (no liquidity cap), expectedVolumeFractionElapsed=schedule fraction (VWAP falls back to TWAP), impactBps=0. NaN in any field is treated as its neutral value — a transient bad input must degrade the input, never silently stall the parent.

Units contract (normalized, so the shipped models plug in directly):

  • volatility — a normalized volatility-REGIME signal, ~0 calm to ~1 extreme: microstructure.VolatilityCurve.regime(bucket, currentVol) produces exactly this (elevated vs the time-of-day baseline). Feeding a raw per-√second return (~1e-4) would make the term inert;
  • alpha — a normalized expected-move signal in [-1, 1] (+ = up): SignalEngine.alpha() plugs in directly. A raw price-return forecast must be rescaled (÷ its typical magnitude) first;
  • displayedDepth — size dealable NOW (displayed top of book). Feeding HiddenLiquidityDetector.estimatedTrueDepth is a conscious choice to size against inferred reserve, not a drop-in.
  • Constructor Details

    • MarketState

      public MarketState(double mid, double spread, double volatility, double displayedDepth, double expectedVolumeFractionElapsed, double alpha, double impactBps)
      Creates an instance of a MarketState record class.
      Parameters:
      mid - the value for the mid record component
      spread - the value for the spread record component
      volatility - the value for the volatility record component
      displayedDepth - the value for the displayedDepth record component
      expectedVolumeFractionElapsed - the value for the expectedVolumeFractionElapsed record component
      alpha - the value for the alpha record component
      impactBps - the value for the impactBps record component
  • Method Details

    • neutral

      public static BenchmarkExecutor.MarketState neutral(double mid, double scheduleFraction)
      A neutral state: no spread/vol/alpha/impact, unlimited depth, VWAP=TWAP.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • mid

      public double mid()
      Returns the value of the mid record component.
      Returns:
      the value of the mid record component
    • spread

      public double spread()
      Returns the value of the spread record component.
      Returns:
      the value of the spread record component
    • volatility

      public double volatility()
      Returns the value of the volatility record component.
      Returns:
      the value of the volatility record component
    • displayedDepth

      public double displayedDepth()
      Returns the value of the displayedDepth record component.
      Returns:
      the value of the displayedDepth record component
    • expectedVolumeFractionElapsed

      public double expectedVolumeFractionElapsed()
      Returns the value of the expectedVolumeFractionElapsed record component.
      Returns:
      the value of the expectedVolumeFractionElapsed record component
    • alpha

      public double alpha()
      Returns the value of the alpha record component.
      Returns:
      the value of the alpha record component
    • impactBps

      public double impactBps()
      Returns the value of the impactBps record component.
      Returns:
      the value of the impactBps record component