@Test public void priceFromCurves() { final double priceComputed = METHOD_SECURITY.priceFromCurves(BILL_IAM_SEC, CURVE_BUNDLE); final CurrencyAmount pvComputed = METHOD_SECURITY.presentValue(BILL_IAM_SEC, CURVE_BUNDLE); final double priceExpected = pvComputed.getAmount() / (NOTIONAL * CURVE_BUNDLE .getCurve(NAME_CURVES[0]) .getDiscountFactor(BILL_IAM_SEC.getSettlementTime())); assertEquals( "Bill Security: discounting method - price", priceExpected, priceComputed, TOLERANCE_PRICE); }
@Test public void presentValueFromYield() { final CurrencyAmount pvComputed = METHOD_SECURITY.presentValueFromYield(BILL_IAM_SEC, YIELD, CURVE_BUNDLE); final double price = METHOD_SECURITY.priceFromYield(BILL_IAM_SEC, YIELD); final double pvExpected = NOTIONAL * price * CURVE_BUNDLE .getCurve(NAME_CURVES[0]) .getDiscountFactor(BILL_IAM_SEC.getSettlementTime()); assertEquals( "Bill Security: discounting method - present value", pvExpected, pvComputed.getAmount(), TOLERANCE_PV); }