//------------------------------------------------------------------------- public virtual void present_value_normal_vol_sensitivity_premium_forward() { PointSensitivities vegaTrade = PRICER_TRADE.presentValueSensitivityModelParamsVolatility(SWAPTION_PREFWD_LONG_REC, MULTI_USD, NORMAL_VOLS_USD); SwaptionSensitivity vegaProduct = PRICER_PRODUCT.presentValueSensitivityModelParamsVolatility(SWAPTION_LONG_REC, MULTI_USD, NORMAL_VOLS_USD); assertEquals(vegaTrade.Sensitivities.get(0).Sensitivity, vegaProduct.Sensitivity, TOLERANCE_PV_VEGA); }
//------------------------------------------------------------------------- public virtual void present_value_sensitivityNormalVolatility_FD() { double shiftVol = 1.0E-4; CurrencyAmount pvP = PRICER_SWAPTION_NORMAL.presentValue(SWAPTION_LONG_PAY, MULTI_USD, SwaptionNormalVolatilityDataSets.normalVolSwaptionProviderUsdStsShifted(shiftVol)); CurrencyAmount pvM = PRICER_SWAPTION_NORMAL.presentValue(SWAPTION_LONG_PAY, MULTI_USD, SwaptionNormalVolatilityDataSets.normalVolSwaptionProviderUsdStsShifted(-shiftVol)); double pvnvsFd = (pvP.Amount - pvM.Amount) / (2 * shiftVol); SwaptionSensitivity pvnvsAd = PRICER_SWAPTION_NORMAL.presentValueSensitivityModelParamsVolatility(SWAPTION_LONG_PAY, MULTI_USD, NORMAL_VOLS_USD_STD); assertEquals(pvnvsAd.Currency, USD); assertEquals(pvnvsAd.Sensitivity, pvnvsFd, TOLERANCE_PV_VEGA); assertEquals(pvnvsAd.VolatilitiesName, NORMAL_VOLS_USD_STD.Name); assertEquals(pvnvsAd.Expiry, NORMAL_VOLS_USD_STD.relativeTime(SWAPTION_LONG_PAY.Expiry)); assertEquals(pvnvsAd.Tenor, SWAP_TENOR_YEAR, TOLERANCE_RATE); assertEquals(pvnvsAd.Strike, STRIKE, TOLERANCE_RATE); double forward = PRICER_SWAP.parRate(RSWAP_REC, MULTI_USD); assertEquals(pvnvsAd.Forward, forward, TOLERANCE_RATE); }
//------------------------------------------------------------------------- /// <summary> /// Calculates the present value sensitivity to the implied volatility of the swaption trade. /// <para> /// The sensitivity to the normal volatility is also called normal vega. /// /// </para> /// </summary> /// <param name="trade"> the swaption trade </param> /// <param name="ratesProvider"> the rates provider </param> /// <param name="swaptionVolatilities"> the volatilities </param> /// <returns> the point sensitivity to the normal volatility </returns> public virtual PointSensitivities presentValueSensitivityModelParamsVolatility(ResolvedSwaptionTrade trade, RatesProvider ratesProvider, NormalSwaptionVolatilities swaptionVolatilities) { ResolvedSwaption product = trade.Product; SwaptionSensitivity pointSens = isCash(product) ? cashParYieldPricer.presentValueSensitivityModelParamsVolatility(product, ratesProvider, swaptionVolatilities) : physicalPricer.presentValueSensitivityModelParamsVolatility(product, ratesProvider, swaptionVolatilities); return(PointSensitivities.of(pointSens)); }