BillTransactionDiscountingMethod { public MulticurveSensitivity parSpreadCurveSensitivity(final BillTransaction bill, final IssuerProviderInterface issuer) { ArgumentChecker.notNull(bill, "Bill"); ArgumentChecker.notNull(issuer, "Issuer and multi-curves provider"); final Currency ccy = bill.getCurrency(); final double dfCreditEnd = issuer.getDiscountFactor(bill.getBillPurchased().getIssuerEntity(), bill.getBillPurchased().getEndTime()); final double dfDscSettle = issuer.getMulticurveProvider().getDiscountFactor(ccy, bill.getBillPurchased().getSettlementTime()); final double pricePar = dfCreditEnd / dfDscSettle; final double spreadBar = 1.0; final double priceParBar = METHOD_SECURITY.yieldFromPriceDerivative(bill.getBillPurchased(), pricePar) * spreadBar; final double dfDscSettleBar = -dfCreditEnd / (dfDscSettle * dfDscSettle) * priceParBar; final double dfCreditEndBar = priceParBar / dfDscSettle; final Map<String, List<DoublesPair>> resultMapCredit = new HashMap<>(); final List<DoublesPair> listCredit = new ArrayList<>(); listCredit.add(DoublesPair.of(bill.getBillPurchased().getEndTime(), -bill.getBillPurchased().getEndTime() * dfCreditEnd * dfCreditEndBar)); resultMapCredit.put(issuer.getName(bill.getBillPurchased().getIssuerEntity()), listCredit); final MulticurveSensitivity result = MulticurveSensitivity.ofYieldDiscounting(resultMapCredit); final Map<String, List<DoublesPair>> resultMapDsc = new HashMap<>(); final List<DoublesPair> listDsc = new ArrayList<>(); listDsc.add(DoublesPair.of(bill.getBillPurchased().getSettlementTime(), -bill.getBillPurchased().getSettlementTime() * dfDscSettle * dfDscSettleBar)); resultMapDsc.put(issuer.getMulticurveProvider().getName(ccy), listDsc); return result.plus(MulticurveSensitivity.ofYieldDiscounting(resultMapDsc)); } private  BillTransactionDiscountingMethod(); static BillTransactionDiscountingMethod getInstance(); MultipleCurrencyAmount presentValue(final BillTransaction bill, final IssuerProviderInterface issuer); MultipleCurrencyAmount presentValueFromYield(final BillTransaction bill, final double yield, final IssuerProviderInterface issuer); MultipleCurrencyMulticurveSensitivity presentValueCurveSensitivity(final BillTransaction bill, final IssuerProviderInterface issuer); double parSpread(final BillTransaction bill, final IssuerProviderInterface issuer); MulticurveSensitivity parSpreadCurveSensitivity(final BillTransaction bill, final IssuerProviderInterface issuer);  }
@Test public void parSpreadCurveSensitivity() { final SimpleParameterSensitivity pspsDepositExact = PS_PSMQ_C.calculateSensitivity(BILL_TRA, ISSUER_MULTICURVE, ISSUER_MULTICURVE.getAllNames()); final SimpleParameterSensitivity pspsDepositFD = PS_PSMQ_FDC.calculateSensitivity(BILL_TRA, ISSUER_MULTICURVE); AssertSensitivityObjects.assertEquals("DepositCounterpartDiscountingMethod: presentValueCurveSensitivity ", pspsDepositExact, pspsDepositFD, TOLERANCE_PV_DELTA); }
@Test public void parSpreadCurveSensitivityMethodVsCalculator() { final MulticurveSensitivity pscsMethod = METHOD_TRANSACTION.parSpreadCurveSensitivity(BILL_TRA, ISSUER_MULTICURVE); final MulticurveSensitivity pscsCalculator = BILL_TRA.accept(PSMQCSIDC, ISSUER_MULTICURVE); AssertSensitivityObjects.assertEquals("parSpread: curve sensitivity - fwd", pscsMethod, pscsCalculator, TOLERANCE_SPREAD_DELTA); }