//------------------------------------------------------------------------- public virtual void test_presentValueSensitivity() { PointSensitivityBuilder point = LEG_PRICER.presentValueSensitivity(COUPON_LEG, RATES_PROVIDER); CurrencyParameterSensitivities computed = RATES_PROVIDER.parameterSensitivity(point.build()); CurrencyParameterSensitivities expected = FD_CAL.sensitivity(RATES_PROVIDER, p => LEG_PRICER.presentValue(COUPON_LEG, p)); assertTrue(computed.equalWithTolerance(expected, TOLERANCE_DELTA)); }
public virtual void test_presentValueSensitivity() { PointSensitivityBuilder pt1 = PRODUCT_PRICER.presentValueSensitivity(CMS_ONE_LEG, RATES_PROVIDER); PointSensitivityBuilder pt2 = PRODUCT_PRICER.presentValueSensitivity(CMS_TWO_LEGS, RATES_PROVIDER); PointSensitivityBuilder ptCms = CMS_LEG_PRICER.presentValueSensitivity(CMS_LEG, RATES_PROVIDER); PointSensitivityBuilder ptPay = SWAP_LEG_PRICER.presentValueSensitivity(PAY_LEG, RATES_PROVIDER); assertEquals(pt1, ptCms); assertEquals(pt2, ptCms.combinedWith(ptPay)); }
/// <summary> /// Calculates the present value curve sensitivity of the CMS product by simple forward estimation. /// <para> /// The present value sensitivity of the product is the sensitivity of the present value to the underlying curves. /// /// </para> /// </summary> /// <param name="cms"> the CMS product </param> /// <param name="ratesProvider"> the rates provider </param> /// <returns> the present value sensitivity </returns> public virtual PointSensitivityBuilder presentValueSensitivity(ResolvedCms cms, RatesProvider ratesProvider) { PointSensitivityBuilder pvSensiCmsLeg = cmsLegPricer.presentValueSensitivity(cms.CmsLeg, ratesProvider); if (!cms.PayLeg.Present) { return(pvSensiCmsLeg); } PointSensitivityBuilder pvSensiPayLeg = swapPricer.LegPricer.presentValueSensitivity(cms.PayLeg.get(), ratesProvider); return(pvSensiCmsLeg.combinedWith(pvSensiPayLeg)); }