//------------------------------------------------------------------------- public virtual void test_pvsensiZSpread_settle_before_val() { PointSensitivities pvsensiComputed = PRICER_TRADE.presentValueSensitivityWithZSpread(BILL_TRADE_SETTLE_BEFORE_VAL, PROVIDER, Z_SPREAD, CompoundedRateType.CONTINUOUS, 0); PointSensitivities pvsensiExpected = PRICER_PRODUCT.presentValueSensitivityWithZSpread(BILL_PRODUCT.resolve(REF_DATA), PROVIDER, Z_SPREAD, CompoundedRateType.CONTINUOUS, 0).multipliedBy(QUANTITY); assertTrue(pvsensiComputed.equalWithTolerance(pvsensiExpected, TOLERANCE_PVSENSI)); CurrencyParameterSensitivities paramSensiComputed = PROVIDER.parameterSensitivity(pvsensiComputed); CurrencyParameterSensitivities paramSensiExpected = FD_CALC.sensitivity(PROVIDER, p => PRICER_TRADE.presentValueWithZSpread(BILL_TRADE_SETTLE_BEFORE_VAL, p, Z_SPREAD, CompoundedRateType.CONTINUOUS, 0)); assertTrue(paramSensiComputed.equalWithTolerance(paramSensiExpected, EPS * NOTIONAL_AMOUNT * QUANTITY)); }
public virtual void presentValueSensitivity_zspread() { PointSensitivities sensiComputed = PRICER.presentValueSensitivityWithZSpread(BILL, PROVIDER, Z_SPREAD, CompoundedRateType.CONTINUOUS, 0); PointSensitivities sensiExpected = IssuerCurveZeroRateSensitivity.of(DSC_FACTORS_ISSUER.zeroRatePointSensitivityWithSpread(MATURITY_DATE, Z_SPREAD, CompoundedRateType.CONTINUOUS, 0), GROUP_ISSUER).multipliedBy(NOTIONAL.Amount).build(); assertTrue(sensiComputed.equalWithTolerance(sensiExpected, TOLERANCE_PV)); CurrencyParameterSensitivities paramSensiComputed = PROVIDER.parameterSensitivity(sensiComputed); CurrencyParameterSensitivities paramSensiExpected = FD_CALC.sensitivity(PROVIDER, p => PRICER.presentValueWithZSpread(BILL, p, Z_SPREAD, CompoundedRateType.CONTINUOUS, 0)); assertTrue(paramSensiComputed.equalWithTolerance(paramSensiExpected, EPS * NOTIONAL_AMOUNT)); }
/// <summary> /// Calculates the present value sensitivity of a bill trade with z-spread. /// <para> /// If the settlement details are provided, the sensitivity is the sum of the underlying product's sensitivity /// multiplied by the quantity and the sensitivity of the settlement payment if still due at the valuation date. /// If not it is the underlying product's sensitivity multiplied by the quantity. /// </para> /// <para> /// The z-spread is a parallel shift applied to continuously compounded rates or periodic compounded rates of /// the issuer discounting curve. The z-spread is applied only on the legal entity curve, not on the repo curve used /// for the settlement amount. /// /// </para> /// </summary> /// <param name="trade"> the trade </param> /// <param name="provider"> the discounting provider </param> /// <param name="zSpread"> the z-spread </param> /// <param name="compoundedRateType"> the compounded rate type </param> /// <param name="periodsPerYear"> the number of periods per year </param> /// <returns> the present value sensitivity </returns> public virtual PointSensitivities presentValueSensitivityWithZSpread(ResolvedBillTrade trade, LegalEntityDiscountingProvider provider, double zSpread, CompoundedRateType compoundedRateType, int periodsPerYear) { if (provider.ValuationDate.isAfter(trade.Product.Notional.Date)) { return(PointSensitivities.empty()); } PointSensitivities sensiProduct = productPricer.presentValueSensitivityWithZSpread(trade.Product, provider, zSpread, compoundedRateType, periodsPerYear).multipliedBy(trade.Quantity); if (!trade.Settlement.Present) { return(sensiProduct); } Payment settlement = trade.Settlement.get(); RepoCurveDiscountFactors repoDf = DiscountingBillProductPricer.repoCurveDf(trade.Product, provider); PointSensitivities sensiSettle = presentValueSensitivitySettlement(settlement, repoDf); return(sensiProduct.combinedWith(sensiSettle)); }