Class CurveGammaCalculator


  • public final class CurveGammaCalculator
    extends Object
    Computes the gamma-related values for the rates curve parameters.

    By default the gamma is computed using a one basis-point shift and a forward finite difference. The results themselves are not scaled (they represent the second order derivative).

    Reference: Interest Rate Cross-gamma for Single and Multiple Curves. OpenGamma quantitative research 15, July 14

    • Field Detail

      • DEFAULT

        public static final CurveGammaCalculator DEFAULT
        Default implementation. Finite difference is forward and the shift is one basis point (0.0001).
    • Method Detail

      • ofForwardDifference

        public static CurveGammaCalculator ofForwardDifference​(double shift)
        Obtains an instance of the finite difference calculator using forward differencing.
        Parameters:
        shift - the shift to be applied to the curves
        Returns:
        the calculator
      • ofCentralDifference

        public static CurveGammaCalculator ofCentralDifference​(double shift)
        Obtains an instance of the finite difference calculator using central differencing.
        Parameters:
        shift - the shift to be applied to the curves
        Returns:
        the calculator
      • ofBackwardDifference

        public static CurveGammaCalculator ofBackwardDifference​(double shift)
        Obtains an instance of the finite difference calculator using backward differencing.
        Parameters:
        shift - the shift to be applied to the curves
        Returns:
        the calculator
      • calculateCrossGammaIntraCurve

        public CrossGammaParameterSensitivities calculateCrossGammaIntraCurve​(RatesProvider ratesProvider,
                                                                              Function<ImmutableRatesProvider,​CurrencyParameterSensitivities> sensitivitiesFn)
        Computes intra-curve cross gamma by applying finite difference method to curve delta.

        This computes the intra-curve cross gamma, i.e., the second order sensitivities to individual curves. Thus the sensitivity of a curve delta to another curve is not produced.

        The sensitivities are computed for discount curves, and forward curves for RateIndex and PriceIndex. This implementation works only for single currency trades.

        Parameters:
        ratesProvider - the rates provider
        sensitivitiesFn - the sensitivity function
        Returns:
        the cross gamma
      • calculateCrossGammaIntraCurve

        public CrossGammaParameterSensitivities calculateCrossGammaIntraCurve​(LegalEntityDiscountingProvider ratesProvider,
                                                                              Function<ImmutableLegalEntityDiscountingProvider,​CurrencyParameterSensitivities> sensitivitiesFn)
        Computes intra-curve cross gamma for bond curves by applying finite difference method to curve delta.

        This computes the intra-curve cross gamma, i.e., the second order sensitivities to individual curves. Thus the sensitivity of a curve delta to another curve is not produced.

        The underlying instruments must be single-currency, i.e., the curve currency must be the same as the sensitivity currency.

        Parameters:
        ratesProvider - the rates provider
        sensitivitiesFn - the sensitivity function
        Returns:
        the cross gamma
      • calculateCrossGammaCrossCurve

        public CrossGammaParameterSensitivities calculateCrossGammaCrossCurve​(RatesProvider ratesProvider,
                                                                              Function<ImmutableRatesProvider,​CurrencyParameterSensitivities> sensitivitiesFn)
        Computes cross-curve gamma by applying finite difference method to curve delta.

        This computes the cross-curve gamma, i.e., the second order sensitivities to full curves. Thus the sensitivities of curve delta to other curves are produced.

        The sensitivities are computed for discount curves, and forward curves for RateIndex and PriceIndex. This implementation works only for single currency trades.

        Parameters:
        ratesProvider - the rates provider
        sensitivitiesFn - the sensitivity function
        Returns:
        the cross gamma
      • calculateSemiParallelGamma

        public CurrencyParameterSensitivity calculateSemiParallelGamma​(Curve curve,
                                                                       Currency curveCurrency,
                                                                       Function<Curve,​CurrencyParameterSensitivity> sensitivitiesFn)
        Computes the "sum-of-column gamma" or "semi-parallel gamma" for a sensitivity function.

        This implementation supports a single Curve on the zero-coupon rates. By default the gamma is computed using a one basis-point shift and a forward finite difference. The results themselves are not scaled (they represent the second order derivative).

        Parameters:
        curve - the single curve to be bumped
        curveCurrency - the currency of the curve and resulting sensitivity
        sensitivitiesFn - the function to convert the bumped curve to parameter sensitivities
        Returns:
        the "sum-of-columns" or "semi-parallel" gamma vector