Class CrbAutoHedger
java.lang.Object
com.quantfinlib.crb.CrbAutoHedger
The central risk book's hedging loop: per-factor exposure BANDS, a
cost-aware hedge when breached, and a cooldown so the book does not
chase its own hedges. The policy is deliberately two-speed:
- inside the bands, warehouse — the whole point of a CRB is that inventory nets against future flow for free;
- on a breach, hedge the breached factors back to
resetFractionof the limit throughHedgeOptimizer— cost-aware first, but if the cost-aware hedge leaves any factor still OUTSIDE its limit the hedge reruns at zero cost weight: a hard limit outranks transaction-cost thrift, always.
Time is a caller-supplied interval counter (no wall clock — deterministic, replayable). Research/warm lane, single-threaded.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordOne instrument's hedge instruction. -
Constructor Summary
ConstructorsConstructorDescriptionCrbAutoHedger(double[] limits, double resetFraction, long cooldownIntervals) -
Method Summary
Modifier and TypeMethodDescriptionbooleanbreached(double[] exposures) True when any factor sits outside its band.check(double[] exposures, double[][] covariance, double[][] loadings, double[] costPerUnit, double costWeight, long nowInterval) The hedging decision for this interval.longdoubletargetBand(int factor) The band the book hedges back INTO for a factor.
-
Constructor Details
-
CrbAutoHedger
public CrbAutoHedger(double[] limits, double resetFraction, long cooldownIntervals) - Parameters:
limits- per-factor |exposure| limits (registry order; > 0 each)resetFraction- post-hedge target as a fraction of the limit, in (0, 1]cooldownIntervals- min intervals between hedges, ≥ 0
-
-
Method Details
-
breached
public boolean breached(double[] exposures) True when any factor sits outside its band. -
check
public CrbAutoHedger.HedgeOrder[] check(double[] exposures, double[][] covariance, double[][] loadings, double[] costPerUnit, double costWeight, long nowInterval) The hedging decision for this interval. Empty when inside all bands or still cooling down; otherwise the cheapest hedge of the EXCESS — only what sits beyondresetFraction·limiton the breached factors is hedged, because inventory inside the band is the CRB's edge, not its problem. If the cost-aware hedge still leaves a factor outside its hard limit, the excess is re-hedged cost-blind (best effort: an instrument set that cannot span a factor cannot fix it at any λ, and the orders go out anyway).- Parameters:
exposures- current factor exposures (registry order)covariance- factor covariance for the optimizerloadings- instrument factor loadings [factor][instrument]costPerUnit- per-unit hedge costscostWeight- λ for the cost-aware first attemptnowInterval- caller's interval counter (monotone)
-
targetBand
public double targetBand(int factor) The band the book hedges back INTO for a factor. -
hedgesEmitted
public long hedgesEmitted()
-