Class CrbHedgeUniverse

java.lang.Object
com.quantfinlib.crb.CrbHedgeUniverse

public final class CrbHedgeUniverse extends Object
The hedge-instrument universe, aligned to a book's factor registry — because hand-assembling loadings[factor][instrument] is the most error-prone step in the whole hedging workflow (one transposed index and the optimizer confidently hedges the wrong thing).

Each instrument declares what ONE UNIT of its notional does to the factor space, in the same conventions CentralRiskBook books with:

Factors named here are REGISTERED on the shared registry if new (a hedge-only factor simply has zero book exposure), and loadings() materializes the matrix at the registry's CURRENT size — build it after all booking and adding is done, and feed it straight to HedgeOptimizer/CrbAutoHedger with costs(). Research lane, single-threaded.

  • Constructor Details

    • CrbHedgeUniverse

      public CrbHedgeUniverse(FactorRegistry registry)
      Parameters:
      registry - the book's registry — book.factors()
  • Method Details

    • addSingleFactor

      public CrbHedgeUniverse addSingleFactor(String name, String factor, double costPerUnit)
      An instrument that is one unit of exactly one factor.
    • addFxForward

      public CrbHedgeUniverse addFxForward(String name, String pair, double rate, double costPerUnit)
      An FX forward/spot hedge on pair: one unit of base notional loads the two currency legs exactly as a booked trade would.
    • add

      public CrbHedgeUniverse add(String name, double costPerUnit, String[] factors, double[] perUnit)
      A general instrument: per-unit loadings onto named factors.
    • loadings

      public double[][] loadings()
      The loadings matrix [factor][instrument] at the registry's CURRENT size — call after all booking/adding, alongside costs().
    • costs

      public double[] costs()
      Per-unit costs aligned with loadings() columns.
    • name

      public String name(int instrument)
      Instrument name for a CrbAutoHedger.HedgeOrder.instrument() index.
    • size

      public int size()