Class GreekHedger

java.lang.Object
com.quantfinlib.hedging.GreekHedger

public final class GreekHedger extends Object
Greek-neutralization: solves the hedge quantities that flatten a portfolio's option Greeks using available hedge instruments — the standard delta-gamma and delta-gamma-vega hedging recipes, plus a general linear solver for arbitrary greek/instrument combinations.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final record 
    Per-unit Greeks of a hedge instrument (the underlying is delta=1, gamma=0, vega=0).
  • Method Summary

    Modifier and Type
    Method
    Description
    static double[]
    deltaGammaHedge(double portfolioDelta, double portfolioGamma, double optionDelta, double optionGamma)
    Delta-gamma hedge with the underlying plus one option: returns [underlyingQty, optionQty] that zero both Greeks.
    static double[]
    deltaGammaVegaHedge(double portfolioDelta, double portfolioGamma, double portfolioVega, GreekHedger.Instrument option1, GreekHedger.Instrument option2)
    Delta-gamma-vega hedge with the underlying plus two options: returns [underlyingQty, option1Qty, option2Qty].
    static double[]
    neutralize(double[] portfolioGreeks, GreekHedger.Instrument[] instruments)
    General case: solves per-instrument quantities so that the summed instrument Greeks exactly offset the portfolio Greeks.
    static double[]
    residualGreeks(double[] portfolioGreeks, GreekHedger.Instrument[] instruments, double[] quantities)
    Residual portfolio Greeks after applying the hedge quantities (for verification).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • deltaGammaHedge

      public static double[] deltaGammaHedge(double portfolioDelta, double portfolioGamma, double optionDelta, double optionGamma)
      Delta-gamma hedge with the underlying plus one option: returns [underlyingQty, optionQty] that zero both Greeks.
    • deltaGammaVegaHedge

      public static double[] deltaGammaVegaHedge(double portfolioDelta, double portfolioGamma, double portfolioVega, GreekHedger.Instrument option1, GreekHedger.Instrument option2)
      Delta-gamma-vega hedge with the underlying plus two options: returns [underlyingQty, option1Qty, option2Qty].
    • neutralize

      public static double[] neutralize(double[] portfolioGreeks, GreekHedger.Instrument[] instruments)
      General case: solves per-instrument quantities so that the summed instrument Greeks exactly offset the portfolio Greeks. The number of instruments must equal the number of Greeks (portfolioGreeks = [delta, gamma, vega][..count]), and the instrument Greeks must be linearly independent.
    • residualGreeks

      public static double[] residualGreeks(double[] portfolioGreeks, GreekHedger.Instrument[] instruments, double[] quantities)
      Residual portfolio Greeks after applying the hedge quantities (for verification).