//------------------------------------------------------------------------- public virtual void price_from_yield_discount() { double yield = 0.01; LocalDate settlementDate = LocalDate.of(2018, 8, 17); double af = US_BILL.DayCount.relativeYearFraction(settlementDate, MATURITY_DATE); double priceExpected = 1.0d - yield * af; double priceComputed = US_BILL.priceFromYield(yield, settlementDate); assertEquals(priceExpected, priceComputed, TOLERANCE_PRICE); }
public virtual void price_from_yield_intatmat() { Bill bill = US_BILL.toBuilder().yieldConvention(BillYieldConvention.INTEREST_AT_MATURITY).build(); double yield = 0.01; LocalDate settlementDate = LocalDate.of(2018, 8, 17); double af = bill.DayCount.relativeYearFraction(settlementDate, MATURITY_DATE); double priceExpected = 1.0d / (1 + yield * af); double priceComputed = bill.priceFromYield(yield, settlementDate); assertEquals(priceExpected, priceComputed, TOLERANCE_PRICE); }