Class HftQuoter

java.lang.Object
com.quantfinlib.trading.HftQuoter
All Implemented Interfaces:
TickListener

public final class HftQuoter extends Object implements TickListener
Streaming two-sided quoter on the fast lane — the market-making loop: tick in → mid → inventory skew → tick-grid snap → two orders out through the HftRiskGate and HftOrderGateway, with zero allocation per tick.

Quote construction per tick (all primitive arithmetic):

   skew = −position × skewPerUnit          (long inventory shades DOWN)
   bid  = mid − halfSpread + skew           → rounded DOWN to the grid
   ask  = mid + halfSpread + skew           → rounded UP   to the grid
 

Inventory comes straight from the risk gate's position (updated by fills via HftRiskGate.onFill(int, com.quantfinlib.orderbook.Side, long)), so the skew loop closes without any extra state. Both sides still pass the gate's own checks — a quoter cannot out-trade its risk limits.

Conflation. Venues throttle quote updates and stale requotes waste the wire: a re-quote is suppressed unless the mid moved at least minMove or minRequoteIntervalNanos elapsed. Suppression is counted, never silent.

Register as a TickListener on the bus (runs on the consumer thread), exactly like a strategy. Single-threaded by construction; the per-symbol state arrays are indexed by dense symbol id.

Mixed books: half-spreads, skews, conflation thresholds and tick grids are per-instrument quantities (a EURUSD half-spread is ~100× too tight for USDJPY), so the constructor's config is only the default — override per symbol with configureSymbol(int, com.quantfinlib.trading.HftQuoter.Config) and one quoter serves the whole book.

  • Constructor Details

  • Method Details

    • configureSymbol

      public HftQuoter configureSymbol(int symbolId, HftQuoter.Config config)
      Per-symbol quoting parameters (cold path — call at setup or on config updates from the same thread that quotes, or before start).
    • onTick

      public void onTick(int symbolId, double price, double size, long timestampNanos)
      The hot path: one tick → (possibly) one two-sided quote. Runs on the bus consumer thread; no allocation, no locks, no boxing.
      Specified by:
      onTick in interface TickListener
    • quoteUpdates

      public long quoteUpdates()
      Quote updates actually sent (each is up to two orders).
    • suppressedUpdates

      public long suppressedUpdates()
      Updates suppressed by conflation.
    • rejectedSides

      public long rejectedSides()
      Individual sides refused by the risk gate or a full ring.