Class AutoHedger
java.lang.Object
com.quantfinlib.trading.AutoHedger
- All Implemented Interfaces:
TickListener
Live position-band auto-hedger on the fast lane — the streaming
counterpart to the batch
hedging.DeltaHedger: while the batch
hedger rebalances on a schedule against a model delta, this one watches
the risk gate's live position on every tick and fires a flattening order
through the HftOrderGateway the moment the band is breached.
|position| > positionBand → submit opposite-side order for the excess
over the band (hedge back TO the band)
Hedging to the band edge rather than to flat is deliberate: it removes
the limit breach with the smallest order, avoids ping-ponging around zero,
and matches how dealer books actually run inventory. A cooldown
(minHedgeIntervalNanos) stops the hedger from stacking orders
while the first hedge's fill is still in flight — positions only update
when fills confirm via HftRiskGate.onFill(int, com.quantfinlib.orderbook.Side, long).
Register as a TickListener on the bus (consumer thread), after
the strategy/quoter listeners so it sees the same tick they acted on.
Zero allocation per tick. For options books, drive the position input
from pricing.IncrementalGreeks delta instead of raw inventory —
the band logic is identical.
-
Constructor Summary
ConstructorsConstructorDescriptionAutoHedger(HftOrderGateway gateway, int maxSymbols, long positionBand, long minHedgeIntervalNanos) -
Method Summary
Modifier and TypeMethodDescriptionlongHedge attempts refused (risk gate or full ring) — monitor this.longHedge orders accepted onto the wire.voidonTick(int symbolId, double price, double size, long timestampNanos) The hot path: band check per tick; an order only on breach.
-
Constructor Details
-
AutoHedger
public AutoHedger(HftOrderGateway gateway, int maxSymbols, long positionBand, long minHedgeIntervalNanos) - Parameters:
positionBand- absolute position tolerated without hedging (> 0)minHedgeIntervalNanos- cooldown between hedges per symbol (>= 0)
-
-
Method Details
-
onTick
public void onTick(int symbolId, double price, double size, long timestampNanos) The hot path: band check per tick; an order only on breach.- Specified by:
onTickin interfaceTickListener
-
hedgesSubmitted
public long hedgesSubmitted()Hedge orders accepted onto the wire. -
hedgesRejected
public long hedgesRejected()Hedge attempts refused (risk gate or full ring) — monitor this.
-