//------------------------------------------------------------------------- public virtual void present_value_vol_sensitivity_premium_forward() { PointSensitivities vegaTrade = PRICER_TRADE.presentValueSensitivityModelParamsSabr(SWAPTION_PREFWD_LONG_REC, RATE_PROVIDER, VOLS); PointSensitivities vegaProduct = PRICER_PRODUCT.presentValueSensitivityModelParamsSabr(SWAPTION_LONG_REC, RATE_PROVIDER, VOLS).build(); assertEquals(vegaTrade, vegaProduct); }
//------------------------------------------------------------------------- /// <summary> /// Calculates the present value sensitivity to the SABR model parameters of the swaption trade. /// <para> /// The sensitivity of the present value to the SABR model parameters, alpha, beta, rho and nu. /// /// </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 SABR model parameters </returns> public virtual PointSensitivities presentValueSensitivityModelParamsSabr(ResolvedSwaptionTrade trade, RatesProvider ratesProvider, SabrSwaptionVolatilities swaptionVolatilities) { ResolvedSwaption product = trade.Product; PointSensitivityBuilder pointSens = isCash(product) ? cashParYieldPricer.presentValueSensitivityModelParamsSabr(product, ratesProvider, swaptionVolatilities) : physicalPricer.presentValueSensitivityModelParamsSabr(product, ratesProvider, swaptionVolatilities); return(pointSens.build()); }
//------------------------------------------------------------------------- public virtual void test_presentValueSensitivityModelParamsSabr() { PointSensitivities sensiRec = SWAPTION_PRICER.presentValueSensitivityModelParamsSabr(SWAPTION_REC_LONG, RATE_PROVIDER, VOLS).build(); PointSensitivities sensiPay = SWAPTION_PRICER.presentValueSensitivityModelParamsSabr(SWAPTION_PAY_SHORT, RATE_PROVIDER, VOLS).build(); double forward = SWAP_PRICER.parRate(RSWAP_REC, RATE_PROVIDER); double pvbp = SWAP_PRICER.LegPricer.pvbp(RSWAP_REC.getLegs(SwapLegType.FIXED).get(0), RATE_PROVIDER); double volatility = VOLS.volatility(SWAPTION_REC_LONG.Expiry, TENOR_YEAR, RATE, forward); double maturity = VOLS.relativeTime(SWAPTION_REC_LONG.Expiry); double[] volSensi = VOLS.Parameters.volatilityAdjoint(maturity, TENOR_YEAR, RATE, forward).Derivatives.toArray(); double vegaRec = pvbp * BlackFormulaRepository.vega(forward + SwaptionSabrRateVolatilityDataSet.SHIFT, RATE + SwaptionSabrRateVolatilityDataSet.SHIFT, maturity, volatility); double vegaPay = -pvbp *BlackFormulaRepository.vega(forward + SwaptionSabrRateVolatilityDataSet.SHIFT, RATE + SwaptionSabrRateVolatilityDataSet.SHIFT, maturity, volatility); assertSensitivity(sensiRec, SabrParameterType.ALPHA, vegaRec * volSensi[2], TOL); assertSensitivity(sensiRec, SabrParameterType.BETA, vegaRec * volSensi[3], TOL); assertSensitivity(sensiRec, SabrParameterType.RHO, vegaRec * volSensi[4], TOL); assertSensitivity(sensiRec, SabrParameterType.NU, vegaRec * volSensi[5], TOL); assertSensitivity(sensiPay, SabrParameterType.ALPHA, vegaPay * volSensi[2], TOL); assertSensitivity(sensiPay, SabrParameterType.BETA, vegaPay * volSensi[3], TOL); assertSensitivity(sensiPay, SabrParameterType.RHO, vegaPay * volSensi[4], TOL); assertSensitivity(sensiPay, SabrParameterType.NU, vegaPay * volSensi[5], TOL); }