BillSecurityDiscountingMethod { public double priceFromYield(final BillSecurity bill, final double yield) { return priceFromYield(bill.getYieldConvention(), yield, bill.getAccrualFactor()); } private  BillSecurityDiscountingMethod(); static BillSecurityDiscountingMethod getInstance(); MultipleCurrencyAmount presentValue(final BillSecurity bill, final IssuerProviderInterface issuer); double priceFromYield(final BillSecurity bill, final double yield); double priceFromYield(final YieldConvention convention, final double yield, final double accrualFactor); double yieldFromCleanPrice(final BillSecurity bill, final double price); double yieldFromPriceDerivative(final BillSecurity bill, final double price); MultipleCurrencyAmount presentValueFromYield(final BillSecurity bill, final double yield, final IssuerProviderInterface issuer); MultipleCurrencyAmount presentValueFromPrice(final BillSecurity bill, final double price, final IssuerProviderInterface issuer); double priceFromCurves(final BillSecurity bill, final IssuerProviderInterface issuer); double yieldFromCurves(final BillSecurity bill, final IssuerProviderInterface issuer); MultipleCurrencyMulticurveSensitivity presentValueCurveSensitivity(final BillSecurity bill, final IssuerProviderInterface issuer);  }
@Test public void priceFromYield() { final double[] yields = new double[] {0.0010, 0.0, -0.0010 }; for (final double yield2 : yields) { final double priceComputed = METHOD_SECURITY.priceFromYield(BILL_BEL_IAM_SEC, yield2); final double priceExpected = 1.0 / (1 + BILL_BEL_IAM_SEC.getAccrualFactor() * yield2); assertEquals("Bill Security: discounting method - price", priceExpected, priceComputed, TOLERANCE_PRICE); } }
@Test public void priceFromYieldExternal() { final double priceComputed = METHOD_SECURITY.priceFromYield(BILL_BEL_IAM_SEC, YIELD); assertEquals("Bill Security: discounting method - price", PRICE, priceComputed, TOLERANCE_PRICE_EXTERNAL); }