public void presentValueSensitivity_zspread_aftermaturity() { PointSensitivities sensiComputed = PRICER.presentValueSensitivityWithZSpread(BILL_PAST, PROVIDER, Z_SPREAD, CompoundedRateType.CONTINUOUS, 0); PointSensitivities sensiExpected = PointSensitivities.empty(); assertTrue(sensiComputed.equalWithTolerance(sensiExpected, TOLERANCE_PV)); }
public 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 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.getAmount()) .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)); }
.presentValueSensitivityWithZSpread(trade.getProduct(), provider, zSpread, compoundedRateType, periodsPerYear) .multipliedBy(trade.getQuantity()); if (!trade.getSettlement().isPresent()) {
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)); }