private PointSensitivities presentValueSensitivitySettlement( Payment settlement, RepoCurveDiscountFactors repoDf) { PointSensitivityBuilder pointSettle = paymentPricer.presentValueSensitivity( settlement, repoDf.getDiscountFactors()); if (pointSettle instanceof ZeroRateSensitivity) { return RepoCurveZeroRateSensitivity.of((ZeroRateSensitivity) pointSettle, repoDf.getRepoGroup()).build(); } return pointSettle.build(); // NoPointSensitivity }
public void test_pvsensi_settle_on_val() { PointSensitivities pvsensiComputed = PRICER_TRADE.presentValueSensitivity(BILL_TRADE_SETTLE_ON_VAL, PROVIDER); PointSensitivities pvsensiExpected = PRICER_PRODUCT.presentValueSensitivity(BILL_PRODUCT.resolve(REF_DATA), PROVIDER) .multipliedBy(QUANTITY) .combinedWith(RepoCurveZeroRateSensitivity.of( (ZeroRateSensitivity) PRICER_PAYMENT.presentValueSensitivity( BILL_TRADE_SETTLE_ON_VAL.getSettlement().get(), PROVIDER.repoCurveDiscountFactors( BILL_PRODUCT.getSecurityId(), BILL_PRODUCT.getLegalEntityId(), BILL_PRODUCT.getCurrency()) .getDiscountFactors()), GROUP_REPO).build()); assertTrue(pvsensiComputed.equalWithTolerance(pvsensiExpected, TOLERANCE_PVSENSI)); CurrencyParameterSensitivities paramSensiComputed = PROVIDER.parameterSensitivity(pvsensiComputed); CurrencyParameterSensitivities paramSensiExpected = FD_CALC.sensitivity( PROVIDER, p -> PRICER_TRADE.presentValue(BILL_TRADE_SETTLE_ON_VAL, p)); assertTrue(paramSensiComputed.equalWithTolerance(paramSensiExpected, EPS * NOTIONAL_AMOUNT * QUANTITY)); }
public void test_pvsensi_settle_after_val() { PointSensitivities pvsensiComputed = PRICER_TRADE.presentValueSensitivity(BILL_TRADE_SETTLE_AFTER_VAL, PROVIDER); PointSensitivities pvsensiExpected = PRICER_PRODUCT.presentValueSensitivity(BILL_PRODUCT.resolve(REF_DATA), PROVIDER) .multipliedBy(QUANTITY) .combinedWith(RepoCurveZeroRateSensitivity.of( (ZeroRateSensitivity) PRICER_PAYMENT.presentValueSensitivity( BILL_TRADE_SETTLE_AFTER_VAL.getSettlement().get(), PROVIDER.repoCurveDiscountFactors( BILL_PRODUCT.getSecurityId(), BILL_PRODUCT.getLegalEntityId(), BILL_PRODUCT.getCurrency()) .getDiscountFactors()), GROUP_REPO).build()); assertTrue(pvsensiComputed.equalWithTolerance(pvsensiExpected, TOLERANCE_PVSENSI)); CurrencyParameterSensitivities paramSensiComputed = PROVIDER.parameterSensitivity(pvsensiComputed); CurrencyParameterSensitivities paramSensiExpected = FD_CALC.sensitivity( PROVIDER, p -> PRICER_TRADE.presentValue(BILL_TRADE_SETTLE_AFTER_VAL, p)); assertTrue(paramSensiComputed.equalWithTolerance(paramSensiExpected, EPS * NOTIONAL_AMOUNT * QUANTITY)); }
public void test_pvsensiZSpread_settle_on_val() { PointSensitivities pvsensiComputed = PRICER_TRADE .presentValueSensitivityWithZSpread(BILL_TRADE_SETTLE_ON_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) .combinedWith(RepoCurveZeroRateSensitivity.of( (ZeroRateSensitivity) PRICER_PAYMENT.presentValueSensitivity( BILL_TRADE_SETTLE_ON_VAL.getSettlement().get(), PROVIDER.repoCurveDiscountFactors( BILL_PRODUCT.getSecurityId(), BILL_PRODUCT.getLegalEntityId(), BILL_PRODUCT.getCurrency()) .getDiscountFactors()), GROUP_REPO).build()); assertTrue(pvsensiComputed.equalWithTolerance(pvsensiExpected, TOLERANCE_PVSENSI)); CurrencyParameterSensitivities paramSensiComputed = PROVIDER.parameterSensitivity(pvsensiComputed); CurrencyParameterSensitivities paramSensiExpected = FD_CALC.sensitivity( PROVIDER, p -> PRICER_TRADE.presentValueWithZSpread(BILL_TRADE_SETTLE_ON_VAL, p, Z_SPREAD, CompoundedRateType.CONTINUOUS, 0)); assertTrue(paramSensiComputed.equalWithTolerance(paramSensiExpected, EPS * NOTIONAL_AMOUNT * QUANTITY)); }
public void test_pvsensiZSpread_settle_after_val() { PointSensitivities pvsensiComputed = PRICER_TRADE .presentValueSensitivityWithZSpread(BILL_TRADE_SETTLE_AFTER_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) .combinedWith(RepoCurveZeroRateSensitivity.of( (ZeroRateSensitivity) PRICER_PAYMENT.presentValueSensitivity( BILL_TRADE_SETTLE_AFTER_VAL.getSettlement().get(), PROVIDER.repoCurveDiscountFactors( BILL_PRODUCT.getSecurityId(), BILL_PRODUCT.getLegalEntityId(), BILL_PRODUCT.getCurrency()) .getDiscountFactors()), GROUP_REPO).build()); assertTrue(pvsensiComputed.equalWithTolerance(pvsensiExpected, TOLERANCE_PVSENSI)); CurrencyParameterSensitivities paramSensiComputed = PROVIDER.parameterSensitivity(pvsensiComputed); CurrencyParameterSensitivities paramSensiExpected = FD_CALC.sensitivity( PROVIDER, p -> PRICER_TRADE.presentValueWithZSpread(BILL_TRADE_SETTLE_AFTER_VAL, p, Z_SPREAD, CompoundedRateType.CONTINUOUS, 0)); assertTrue(paramSensiComputed.equalWithTolerance(paramSensiExpected, EPS * NOTIONAL_AMOUNT * QUANTITY)); }