Class CrbAutoHedger

java.lang.Object
com.quantfinlib.crb.CrbAutoHedger

public final class CrbAutoHedger extends Object
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 resetFraction of the limit through HedgeOptimizer — 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 Classes
    Modifier and Type
    Class
    Description
    static final record 
    One instrument's hedge instruction.
  • Constructor Summary

    Constructors
    Constructor
    Description
    CrbAutoHedger(double[] limits, double resetFraction, long cooldownIntervals)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    breached(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.
    long
     
    double
    targetBand(int factor)
    The band the book hedges back INTO for a factor.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 beyond resetFraction·limit on 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 optimizer
      loadings - instrument factor loadings [factor][instrument]
      costPerUnit - per-unit hedge costs
      costWeight - λ for the cost-aware first attempt
      nowInterval - 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()