BillTransactionDiscountingMethod { public double parSpread(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; return METHOD_SECURITY.yieldFromCleanPrice(bill.getBillPurchased(), pricePar) - METHOD_SECURITY.yieldFromCleanPrice(bill.getBillPurchased(), -bill.getSettlementAmount() / (bill.getQuantity() * bill.getBillPurchased().getNotional())); } 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 parSpread() { final double spread = METHOD_TRANSACTION.parSpread(BILL_TRA, ISSUER_MULTICURVE); final BillTransactionDefinition bill0Definition = BillTransactionDefinition.fromYield(BILL_SEC_DEFINITION, QUANTITY, SETTLE_DATE, YIELD + spread, CALENDAR); final BillTransaction bill0 = bill0Definition.toDerivative(REFERENCE_DATE); final MultipleCurrencyAmount pv0 = METHOD_TRANSACTION.presentValue(bill0, ISSUER_MULTICURVE); assertEquals("Bill Security: discounting method - par spread", 0, pv0.getAmount(EUR), TOLERANCE_PV); }
@Test public void parSpreadMethodVsCalculator() { final double spreadMethod = METHOD_TRANSACTION.parSpread(BILL_TRA, ISSUER_MULTICURVE); final double spreadCalculator = BILL_TRA.accept(PSMQIDC, ISSUER_MULTICURVE); assertEquals("Bill Security: discounting method - par spread", spreadMethod, spreadCalculator, TOLERANCE_SPREAD); }