DepositCounterpartDiscountingMethod { public MulticurveSensitivity parSpreadCurveSensitivity(final DepositCounterpart deposit, final IssuerProviderInterface multicurves) { ArgumentChecker.notNull(deposit, "Deposit"); ArgumentChecker.notNull(multicurves, "Multicurves"); ArgumentChecker.isTrue(deposit.getNotional() != 0.0, "Notional is 0"); final double dfStart = multicurves.getDiscountFactor(deposit.getCounterparty(), deposit.getStartTime()); final double dfEnd = multicurves.getDiscountFactor(deposit.getCounterparty(), deposit.getEndTime()); final double parSpreadBar = 1.0; final double dfEndBar = -(deposit.getInitialAmount() * dfStart / (dfEnd * dfEnd)) / (deposit.getNotional() * deposit.getAccrualFactor()) * parSpreadBar; final double dfStartBar = (deposit.getInitialAmount() / dfEnd) / (deposit.getNotional() * deposit.getAccrualFactor()) * parSpreadBar; final Map<String, List<DoublesPair>> mapDsc = new HashMap<>(); final List<DoublesPair> listDiscounting = new ArrayList<>(); listDiscounting.add(DoublesPair.of(deposit.getStartTime(), -deposit.getStartTime() * dfStart * dfStartBar)); listDiscounting.add(DoublesPair.of(deposit.getEndTime(), -deposit.getEndTime() * dfEnd * dfEndBar)); mapDsc.put(multicurves.getName(deposit.getCounterparty()), listDiscounting); return MulticurveSensitivity.ofYieldDiscounting(mapDsc); } private  DepositCounterpartDiscountingMethod(); static DepositCounterpartDiscountingMethod getInstance(); MultipleCurrencyAmount presentValue(final DepositCounterpart deposit, final IssuerProviderInterface multicurves); MultipleCurrencyMulticurveSensitivity presentValueCurveSensitivity(final DepositCounterpart deposit, final IssuerProviderInterface multicurves); double parSpread(final DepositCounterpart deposit, final IssuerProviderInterface multicurves); MulticurveSensitivity parSpreadCurveSensitivity(final DepositCounterpart deposit, final IssuerProviderInterface multicurves);  }
@Test public void parSpreadCurveSensitivity() { final ZonedDateTime referenceDate = TRADE_DATE; final DepositCounterpart deposit = DEPOSIT_CPTY_DEFINITION.toDerivative(referenceDate); final SimpleParameterSensitivity pspsDepositExact = PS_PSMQ_C.calculateSensitivity(deposit, PROVIDER_ISSUER, PROVIDER_ISSUER.getAllNames()); final SimpleParameterSensitivity pspsDepositFD = PS_PSMQ_FDC.calculateSensitivity(deposit, PROVIDER_ISSUER); AssertSensitivityObjects.assertEquals("DepositCounterpartDiscountingMethod: presentValueCurveSensitivity ", pspsDepositExact, pspsDepositFD, TOLERANCE_PV_DELTA); }
@Test public void parSpreadCurveSensitivityMethodVsCalculator() { final ZonedDateTime referenceDate = TRADE_DATE; final DepositCounterpart deposit = DEPOSIT_CPTY_DEFINITION.toDerivative(referenceDate); final MulticurveSensitivity pscsMethod = METHOD_DEPOSIT.parSpreadCurveSensitivity(deposit, PROVIDER_ISSUER); final MulticurveSensitivity pscsCalculator = deposit.accept(PSMQCSIDC, PROVIDER_ISSUER); AssertSensitivityObjects.assertEquals("CashDiscountingProviderMethod: parSpreadCurveSensitivity", pscsMethod, pscsCalculator, TOLERANCE_SPREAD); }