BondTotalReturnSwapDiscountingMethod { public MultipleCurrencyAmount presentValue(final BondTotalReturnSwap trs, final IssuerProviderInterface issuerMulticurves) { ArgumentChecker.notNull(trs, "bond TRS"); ArgumentChecker.notNull(issuerMulticurves, "issuer and multi-curve provider"); final MultipleCurrencyAmount fundingLegPV = trs.getFundingLeg().accept(PVIC, issuerMulticurves); final MultipleCurrencyAmount bondPV = trs.getAsset().accept(PVIC, issuerMulticurves).multipliedBy(trs.getQuantity()); return bondPV.plus(fundingLegPV); } private  BondTotalReturnSwapDiscountingMethod(); static BondTotalReturnSwapDiscountingMethod getInstance(); MultipleCurrencyAmount presentValue(final BondTotalReturnSwap trs, final IssuerProviderInterface issuerMulticurves); MultipleCurrencyAmount presentValueAssetLeg(final BondTotalReturnSwap trs, final IssuerProviderInterface issuerMulticurves); MultipleCurrencyAmount presentValueAssetLeg(final BillTotalReturnSwap trs, final IssuerProviderInterface issuerMulticurves); MultipleCurrencyAmount presentValueFundingLeg(final BondTotalReturnSwap trs, final IssuerProviderInterface issuerMulticurves); MultipleCurrencyAmount presentValueFundingLeg(final BillTotalReturnSwap trs, final IssuerProviderInterface issuerMulticurves); MultipleCurrencyMulticurveSensitivity presentValueCurveSensitivity(final BondTotalReturnSwap trs, final IssuerProviderInterface issuerMulticurves);  }
@Test public void presentValueFixedSameCurrencyBeforeEffective() { MultipleCurrencyAmount pvComputedPay = METHOD_TRS_BND.presentValue(TRS_PAY_FIXED_REC_1, ISSUER_MULTICURVE); assertEquals("BondTRSDiscountingMethod: present value", 1, pvComputedPay.size()); assertTrue("BondTRSDiscountingMethod: present value", pvComputedPay.getAmount(GBP) != 0.0); MultipleCurrencyAmount pvBondUnit = UKT14_1_1.accept(PVIC, ISSUER_MULTICURVE); MultipleCurrencyAmount pvFunding = FUNDING_LEG_FIXED_REC_1.accept(PVDC, ISSUER_MULTICURVE.getMulticurveProvider()); MultipleCurrencyAmount pvExpected = pvBondUnit.multipliedBy(-NOTIONAL_BND).plus(pvFunding); assertEquals("BondTRSDiscountingMethod: present value", pvExpected.getAmount(GBP), pvComputedPay.getAmount(GBP), TOLERANCE_PV); MultipleCurrencyAmount pvComputedRec = METHOD_TRS_BND.presentValue(TRS_REC_FIXED_PAY_1, ISSUER_MULTICURVE); assertEquals("BondTRSDiscountingMethod: present value", -pvComputedPay.getAmount(GBP), pvComputedRec.getAmount(GBP), TOLERANCE_PV); }
@Test public void presentValueFixedSameCurrencyAfterEffective() { MultipleCurrencyAmount pvComputed = METHOD_TRS_BND.presentValue(TRS_PAY_FIXED_REC_2, ISSUER_MULTICURVE); assertEquals("BondTRSDiscountingMethod: present value", 1, pvComputed.size()); assertTrue("BondTRSDiscountingMethod: present value", pvComputed.getAmount(GBP) != 0.0); MultipleCurrencyAmount pvBondUnit = UKT14_2_1.accept(PVIC, ISSUER_MULTICURVE); MultipleCurrencyAmount pvFunding = FUNDING_LEG_FIXED_REC_2.accept(PVDC, ISSUER_MULTICURVE.getMulticurveProvider()); MultipleCurrencyAmount pvExpected = pvBondUnit.multipliedBy(-NOTIONAL_BND).plus(pvFunding); assertEquals("BondTRSDiscountingMethod: present value", pvExpected.getAmount(GBP), pvComputed.getAmount(GBP), TOLERANCE_PV); }
@Test public void presentValueIborDiffCurrencyBeforeEffective() { MultipleCurrencyAmount pvComputedRec = METHOD_TRS_BND.presentValue(TRS_REC_IBOR_PAY_1_EFF, ISSUER_MULTICURVE); assertEquals("BondTRSDiscountingMethod: present value", 2, pvComputedRec.size()); assertTrue("BondTRSDiscountingMethod: present value", pvComputedRec.getAmount(GBP) != 0.0); assertTrue("BondTRSDiscountingMethod: present value", pvComputedRec.getAmount(USD) != 0.0); MultipleCurrencyAmount pvBondUnit = UKT14_1_2.accept(PVIC, ISSUER_MULTICURVE); MultipleCurrencyAmount pvFunding = FUNDING_LEG_IBOR_PAY_1.accept(PVDC, ISSUER_MULTICURVE.getMulticurveProvider()); MultipleCurrencyAmount pvExpected = pvBondUnit.multipliedBy(NOTIONAL_BND).plus(pvFunding); assertEquals("BondTRSDiscountingMethod: present value", pvExpected.getAmount(GBP), pvComputedRec.getAmount(GBP), TOLERANCE_PV); assertEquals("BondTRSDiscountingMethod: present value", pvFunding.getAmount(USD), pvComputedRec.getAmount(USD), TOLERANCE_PV); MultipleCurrencyAmount pvComputedRecStd = METHOD_TRS_BND.presentValue(TRS_REC_IBOR_PAY_1_STD, ISSUER_MULTICURVE); assertFalse("", Math.abs(pvComputedRec.getAmount(GBP) - pvComputedRecStd.getAmount(GBP)) < TOLERANCE_PV); }
@Test public void presentValueMethodVsCalculator() { MultipleCurrencyAmount pvMethod = METHOD_TRS_BND.presentValue(TRS_REC_IBOR_PAY_1_EFF, ISSUER_MULTICURVE); MultipleCurrencyAmount pvCalculator = TRS_REC_IBOR_PAY_1_EFF.accept(PVIC, ISSUER_MULTICURVE); assertEquals("BondTRSDiscountingMethod: present value", pvMethod.getAmount(GBP), pvCalculator.getAmount(GBP), TOLERANCE_PV); assertEquals("BondTRSDiscountingMethod: present value", pvMethod.getAmount(USD), pvCalculator.getAmount(USD), TOLERANCE_PV); }