Class SabrSwaptionCalibrator


  • public final class SabrSwaptionCalibrator
    extends Object
    Swaption SABR calibrator.

    This calibrator takes raw data and produces calibrated SABR parameters.

    • Method Detail

      • of

        public static SabrSwaptionCalibrator of​(SabrVolatilityFormula sabrVolatilityFormula,
                                                DiscountingSwapProductPricer swapPricer)
        Obtains an instance from a SABR volatility function provider and a swap pricer.

        The swap pricer is used to compute the forward rate required for calibration.

        Parameters:
        sabrVolatilityFormula - the SABR implied volatility formula
        swapPricer - the swap pricer
        Returns:
        the calibrator
      • of

        public static SabrSwaptionCalibrator of​(SabrVolatilityFormula sabrVolatilityFormula,
                                                DiscountingSwapProductPricer swapPricer,
                                                ReferenceData refData)
        Obtains an instance from a SABR volatility function provider and a swap pricer.

        The swap pricer is used to compute the forward rate required for calibration.

        Parameters:
        sabrVolatilityFormula - the SABR implied volatility formula
        swapPricer - the swap pricer
        refData - the reference data
        Returns:
        the calibrator
      • calibrateWithFixedBetaAndShift

        public SabrParametersSwaptionVolatilities calibrateWithFixedBetaAndShift​(SabrSwaptionDefinition definition,
                                                                                 ZonedDateTime calibrationDateTime,
                                                                                 TenorRawOptionData data,
                                                                                 RatesProvider ratesProvider,
                                                                                 Surface betaSurface,
                                                                                 Surface shiftSurface)
        Calibrate SABR parameters to a set of raw swaption data.

        The SABR parameters are calibrated with fixed beta and fixed shift surfaces. The raw data can be (shifted) log-normal volatilities, normal volatilities or option prices

        Parameters:
        definition - the definition of the calibration to be performed
        calibrationDateTime - the data and time of the calibration
        data - the map of raw option data, keyed by tenor
        ratesProvider - the rate provider used to compute the swap forward rates
        betaSurface - the beta surface
        shiftSurface - the shift surface
        Returns:
        the SABR volatility object
      • calibrateWithFixedBetaAndShift

        public SabrParametersSwaptionVolatilities calibrateWithFixedBetaAndShift​(SabrSwaptionDefinition definition,
                                                                                 ZonedDateTime calibrationDateTime,
                                                                                 TenorRawOptionData data,
                                                                                 RatesProvider ratesProvider,
                                                                                 Surface betaSurface,
                                                                                 Surface shiftSurface,
                                                                                 boolean stopOnMathException)
        Calibrate SABR parameters to a set of raw swaption data.

        The SABR parameters are calibrated with fixed beta and fixed shift surfaces. The raw data can be (shifted) log-normal volatilities, normal volatilities or option prices

        This method offers the flexibility to skip the data sets that throw a MathException (stopOnMathException = false). The option to skip those data sets should be use with care, as part of the input data may be unused in the output.

        Parameters:
        definition - the definition of the calibration to be performed
        calibrationDateTime - the data and time of the calibration
        data - the map of raw option data, keyed by tenor
        ratesProvider - the rate provider used to compute the swap forward rates
        betaSurface - the beta surface
        shiftSurface - the shift surface
        stopOnMathException - flag indicating if the calibration should stop on math exceptions or skip the expiries/tenors which throw MathException
        Returns:
        the SABR volatility object
      • calibrateAlphaWithAtm

        public SabrParametersSwaptionVolatilities calibrateAlphaWithAtm​(SwaptionVolatilitiesName name,
                                                                        SabrParametersSwaptionVolatilities sabr,
                                                                        RatesProvider ratesProvider,
                                                                        SwaptionVolatilities atmVolatilities,
                                                                        List<Tenor> tenors,
                                                                        List<Period> expiries,
                                                                        SurfaceInterpolator interpolator)
        Calibrate SABR alpha parameters to a set of ATM swaption volatilities.

        The SABR parameters are calibrated with all the parameters other than alpha (beta, rhu, nu, shift) fixed. The at-the-money volatilities can be log-normal or normal volatilities.

        Parameters:
        name - the name
        sabr - the SABR parameters from which the beta, rho, nu and shift are extracted
        ratesProvider - the rate provider used to compute the swap forward rates
        atmVolatilities - the swaption volatilities containing the ATM volatilities to be calibrated
        tenors - the tenors for which the alpha parameter should be calibrated
        expiries - the expiries for which the alpha parameter should be calibrated
        interpolator - the interpolator for the alpha surface
        Returns:
        the SABR volatility object
      • calibrateLsShiftedFromBlackVolatilities

        public Pair<LeastSquareResultsWithTransform,​DoubleArray> calibrateLsShiftedFromBlackVolatilities​(BusinessDayAdjustment bda,
                                                                                                               ZonedDateTime calibrationDateTime,
                                                                                                               DayCount dayCount,
                                                                                                               Period periodToExpiry,
                                                                                                               double forward,
                                                                                                               DoubleArray strikesLike,
                                                                                                               ValueType strikeType,
                                                                                                               DoubleArray blackVolatilitiesInput,
                                                                                                               double shiftInput,
                                                                                                               DoubleArray startParameters,
                                                                                                               BitSet fixedParameters,
                                                                                                               double shiftOutput)
        Calibrate the SABR parameters to a set of Black volatilities at given moneyness by least square.

        All the associated swaptions have the same expiration date, given by a period from calibration time, and the same tenor.

        Parameters:
        bda - the business day adjustment for the exercise date adjustment
        calibrationDateTime - the calibration date and time
        dayCount - the day count for the computation of the time to exercise
        periodToExpiry - the period to expiry
        forward - the forward price/rate
        strikesLike - the options strike-like dimension
        strikeType - the strike type
        blackVolatilitiesInput - the option (call/payer) implied volatilities in shifted Black model
        shiftInput - the shift used to computed the input implied shifted Black volatilities
        startParameters - the starting parameters for the calibration. If one or more of the parameters are fixed, the starting value will be used as the fixed parameter.
        fixedParameters - the flag for the fixed parameters that are not calibrated
        shiftOutput - the shift to calibrate the shifted SABR
        Returns:
        the least square results and the derivative of the shifted log-normal used for calibration with respect to the raw data
      • calibrateAtmShiftedFromBlackVolatilities

        public Pair<Double,​Double> calibrateAtmShiftedFromBlackVolatilities​(BusinessDayAdjustment bda,
                                                                                  ZonedDateTime calibrationDateTime,
                                                                                  DayCount dayCount,
                                                                                  Period periodToExpiry,
                                                                                  double forward,
                                                                                  double blackVolatility,
                                                                                  double shiftInput,
                                                                                  DoubleArray startParameters,
                                                                                  double shiftOutput)
        Calibrate the SABR alpha parameter to an ATM Black volatility and compute the derivative of the result with respect to the input volatility.
        Parameters:
        bda - the business day adjustment for the exercise date adjustment
        calibrationDateTime - the calibration date and time
        dayCount - the day count for the computation of the time to exercise
        periodToExpiry - the period to expiry
        forward - the forward price/rate
        blackVolatility - the option (call/payer) Black implied volatility
        shiftInput - the shift used to computed the input implied shifted Black volatilities
        startParameters - the starting parameters for the calibration. The alpha parameter is used as a starting point for the root-finding, the other parameters are fixed.
        shiftOutput - the shift to calibrate the shifted SABR
        Returns:
        the alpha calibrated and its derivative with respect to the volatility
      • blackVolatilitiesShiftedFromBlackVolatilitiesShifted

        public Pair<DoubleArray,​DoubleArray> blackVolatilitiesShiftedFromBlackVolatilitiesShifted​(double forward,
                                                                                                        double shiftOutput,
                                                                                                        double timeToExpiry,
                                                                                                        DoubleArray strikes,
                                                                                                        DoubleArray blackVolatilities,
                                                                                                        double shiftInput)
        Creates an array of shifted Black volatilities from shifted Black volatilities with a different shift and the sensitivities of the Black volatilities outputs with respect to the normal volatilities inputs.
        Parameters:
        forward - the forward rate
        shiftOutput - the shift required in the output
        timeToExpiry - the time to expiration
        strikes - the option strikes
        blackVolatilities - the shifted implied Black volatilities
        shiftInput - the shift used in the input Black implied volatilities
        Returns:
        the shifted black volatilities and their derivatives
      • calibrateLsShiftedFromPrices

        public Pair<LeastSquareResultsWithTransform,​DoubleArray> calibrateLsShiftedFromPrices​(BusinessDayAdjustment bda,
                                                                                                    ZonedDateTime calibrationDateTime,
                                                                                                    DayCount dayCount,
                                                                                                    Period periodToExpiry,
                                                                                                    double forward,
                                                                                                    DoubleArray strikesLike,
                                                                                                    ValueType strikeType,
                                                                                                    DoubleArray prices,
                                                                                                    DoubleArray startParameters,
                                                                                                    BitSet fixedParameters,
                                                                                                    double shiftOutput)
        Calibrate the SABR parameters to a set of option prices at given moneyness.

        All the associated swaptions have the same expiration date, given by a period from calibration time, and the same tenor.

        Parameters:
        bda - the business day adjustment for the exercise date adjustment
        calibrationDateTime - the calibration date and time
        dayCount - the day count for the computation of the time to exercise
        periodToExpiry - the period to expiry
        forward - the forward price/rate
        strikesLike - the options strike-like dimension
        strikeType - the strike type
        prices - the option (call/payer) prices
        startParameters - the starting parameters for the calibration. If one or more of the parameters are fixed, the starting value will be used as the fixed parameter.
        fixedParameters - the flag for the fixed parameters that are not calibrated
        shiftOutput - the shift to calibrate the shifted SABR
        Returns:
        SABR parameters
      • blackVolatilitiesShiftedFromPrices

        public Pair<DoubleArray,​DoubleArray> blackVolatilitiesShiftedFromPrices​(double forward,
                                                                                      double shiftOutput,
                                                                                      double timeToExpiry,
                                                                                      DoubleArray strikes,
                                                                                      DoubleArray prices)
        Creates an array of shifted Black volatilities from option prices and the sensitivities of the Black volatilities with respect to the price inputs.
        Parameters:
        forward - the forward rate
        shiftOutput - the shift required in the output
        timeToExpiry - the time to expiration
        strikes - the option strikes
        prices - the option prices
        Returns:
        the shifted black volatilities and their derivatives
      • calibrateLsShiftedFromNormalVolatilities

        public Pair<LeastSquareResultsWithTransform,​DoubleArray> calibrateLsShiftedFromNormalVolatilities​(BusinessDayAdjustment bda,
                                                                                                                ZonedDateTime calibrationDateTime,
                                                                                                                DayCount dayCount,
                                                                                                                Period periodToExpiry,
                                                                                                                double forward,
                                                                                                                DoubleArray strikesLike,
                                                                                                                ValueType strikeType,
                                                                                                                DoubleArray normalVolatilities,
                                                                                                                DoubleArray startParameters,
                                                                                                                BitSet fixedParameters,
                                                                                                                double shiftOutput)
        Calibrate the SABR parameters to a set of normal volatilities at given moneyness.

        All the associated swaptions have the same expiration date, given by a period from calibration time, and the same tenor.

        Parameters:
        bda - the business day adjustment for the exercise date adjustment
        calibrationDateTime - the calibration date and time
        dayCount - the day count for the computation of the time to exercise
        periodToExpiry - the period to expiry
        forward - the forward price/rate
        strikesLike - the options strike-like dimension
        strikeType - the strike type
        normalVolatilities - the option (call/payer) normal model implied volatilities
        startParameters - the starting parameters for the calibration. If one or more of the parameters are fixed, the starting value will be used as the fixed parameter.
        fixedParameters - the flag for the fixed parameters that are not calibrated
        shiftOutput - the shift to calibrate the shifted SABR
        Returns:
        the least square results and the derivative of the shifted log-normal used for calibration with respect to the raw data
      • calibrateAtmShiftedFromNormalVolatilities

        public Pair<Double,​Double> calibrateAtmShiftedFromNormalVolatilities​(BusinessDayAdjustment bda,
                                                                                   ZonedDateTime calibrationDateTime,
                                                                                   DayCount dayCount,
                                                                                   Period periodToExpiry,
                                                                                   double forward,
                                                                                   double normalVolatility,
                                                                                   DoubleArray startParameters,
                                                                                   double shiftOutput)
        Calibrate the SABR alpha parameter to an ATM normal volatility and compute the derivative of the result with respect to the input volatility.
        Parameters:
        bda - the business day adjustment for the exercise date adjustment
        calibrationDateTime - the calibration date and time
        dayCount - the day count for the computation of the time to exercise
        periodToExpiry - the period to expiry
        forward - the forward price/rate
        normalVolatility - the option (call/payer) normal model implied volatility
        startParameters - the starting parameters for the calibration. The alpha parameter is used as a starting point for the root-finding, the other parameters are fixed.
        shiftOutput - the shift to calibrate the shifted SABR
        Returns:
        the alpha calibrated and its derivative with respect to the volatility
      • blackVolatilitiesShiftedFromNormalVolatilities

        public Pair<DoubleArray,​DoubleArray> blackVolatilitiesShiftedFromNormalVolatilities​(double forward,
                                                                                                  double shiftOutput,
                                                                                                  double timeToExpiry,
                                                                                                  DoubleArray strikes,
                                                                                                  DoubleArray normalVolatilities)
        Creates an array of shifted Black volatilities from Normal volatilities and the sensitivities of the Black volatilities with respect to the normal volatilities inputs.

        The transformation between normal and Black volatility is done using BlackFormulaRepository.impliedVolatilityFromNormalApproximated(double, double, double, double).

        Parameters:
        forward - the forward rate
        shiftOutput - the shift required in the output
        timeToExpiry - the time to expiration
        strikes - the option strikes
        normalVolatilities - the normal volatilities
        Returns:
        the shifted black volatilities and their derivatives