Class SabrSwaptionCalibrator
- java.lang.Object
-
- com.opengamma.strata.pricer.swaption.SabrSwaptionCalibrator
-
public final class SabrSwaptionCalibrator extends Object
Swaption SABR calibrator.This calibrator takes raw data and produces calibrated SABR parameters.
-
-
Field Summary
Fields Modifier and Type Field Description static SabrSwaptionCalibrator
DEFAULT
The default instance of the class.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.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.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.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.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.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.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.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.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.SabrParametersSwaptionVolatilities
calibrateWithFixedBetaAndShift(SabrSwaptionDefinition definition, ZonedDateTime calibrationDateTime, TenorRawOptionData data, RatesProvider ratesProvider, Surface betaSurface, Surface shiftSurface)
Calibrate SABR parameters to a set of raw swaption data.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.static SabrSwaptionCalibrator
of(SabrVolatilityFormula sabrVolatilityFormula, DiscountingSwapProductPricer swapPricer)
Obtains an instance from a SABR volatility function provider and a swap pricer.static SabrSwaptionCalibrator
of(SabrVolatilityFormula sabrVolatilityFormula, DiscountingSwapProductPricer swapPricer, ReferenceData refData)
Obtains an instance from a SABR volatility function provider and a swap pricer.
-
-
-
Field Detail
-
DEFAULT
public static final SabrSwaptionCalibrator DEFAULT
The default instance of the class.
-
-
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 formulaswapPricer
- 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 formulaswapPricer
- the swap pricerrefData
- 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 performedcalibrationDateTime
- the data and time of the calibrationdata
- the map of raw option data, keyed by tenorratesProvider
- the rate provider used to compute the swap forward ratesbetaSurface
- the beta surfaceshiftSurface
- 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 performedcalibrationDateTime
- the data and time of the calibrationdata
- the map of raw option data, keyed by tenorratesProvider
- the rate provider used to compute the swap forward ratesbetaSurface
- the beta surfaceshiftSurface
- the shift surfacestopOnMathException
- 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 namesabr
- the SABR parameters from which the beta, rho, nu and shift are extractedratesProvider
- the rate provider used to compute the swap forward ratesatmVolatilities
- the swaption volatilities containing the ATM volatilities to be calibratedtenors
- the tenors for which the alpha parameter should be calibratedexpiries
- the expiries for which the alpha parameter should be calibratedinterpolator
- 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 adjustmentcalibrationDateTime
- the calibration date and timedayCount
- the day count for the computation of the time to exerciseperiodToExpiry
- the period to expiryforward
- the forward price/ratestrikesLike
- the options strike-like dimensionstrikeType
- the strike typeblackVolatilitiesInput
- the option (call/payer) implied volatilities in shifted Black modelshiftInput
- the shift used to computed the input implied shifted Black volatilitiesstartParameters
- 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 calibratedshiftOutput
- 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 adjustmentcalibrationDateTime
- the calibration date and timedayCount
- the day count for the computation of the time to exerciseperiodToExpiry
- the period to expiryforward
- the forward price/rateblackVolatility
- the option (call/payer) Black implied volatilityshiftInput
- the shift used to computed the input implied shifted Black volatilitiesstartParameters
- 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 rateshiftOutput
- the shift required in the outputtimeToExpiry
- the time to expirationstrikes
- the option strikesblackVolatilities
- the shifted implied Black volatilitiesshiftInput
- 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 adjustmentcalibrationDateTime
- the calibration date and timedayCount
- the day count for the computation of the time to exerciseperiodToExpiry
- the period to expiryforward
- the forward price/ratestrikesLike
- the options strike-like dimensionstrikeType
- the strike typeprices
- the option (call/payer) pricesstartParameters
- 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 calibratedshiftOutput
- 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 rateshiftOutput
- the shift required in the outputtimeToExpiry
- the time to expirationstrikes
- the option strikesprices
- 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 adjustmentcalibrationDateTime
- the calibration date and timedayCount
- the day count for the computation of the time to exerciseperiodToExpiry
- the period to expiryforward
- the forward price/ratestrikesLike
- the options strike-like dimensionstrikeType
- the strike typenormalVolatilities
- the option (call/payer) normal model implied volatilitiesstartParameters
- 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 calibratedshiftOutput
- 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 adjustmentcalibrationDateTime
- the calibration date and timedayCount
- the day count for the computation of the time to exerciseperiodToExpiry
- the period to expiryforward
- the forward price/ratenormalVolatility
- the option (call/payer) normal model implied volatilitystartParameters
- 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 rateshiftOutput
- the shift required in the outputtimeToExpiry
- the time to expirationstrikes
- the option strikesnormalVolatilities
- the normal volatilities- Returns:
- the shifted black volatilities and their derivatives
-
-