// This type of "forward" for the day before is required when the publication offset is 1. // The fixing for the previous day will still be unknown at the beginning of the day and need to be computed from the curve. public virtual void test_periodRate_publication_1() { DiscountOvernightIndexRates test = DiscountOvernightIndexRates.of(USD_FED_FUND, DFCURVE, SERIES); double accrualFactor = USD_FED_FUND.DayCount.yearFraction(DATE_BEFORE, DATE_VAL); double expected = (DFCURVE.discountFactor(DATE_BEFORE) / DFCURVE.discountFactor(DATE_VAL) - 1) / accrualFactor; assertEquals(test.periodRate(USD_FEDFUND_BEFORE, DATE_VAL), expected, 1e-8); }
//------------------------------------------------------------------------- public virtual void test_periodRate() { DiscountOvernightIndexRates test = DiscountOvernightIndexRates.of(GBP_SONIA, DFCURVE, SERIES); double accrualFactor = GBP_SONIA.DayCount.yearFraction(DATE_AFTER, DATE_AFTER_END); double expected = (DFCURVE.discountFactor(DATE_AFTER) / DFCURVE.discountFactor(DATE_AFTER_END) - 1) / accrualFactor; assertEquals(test.periodRate(GBP_SONIA_AFTER, DATE_AFTER_END), expected, 1e-8); }
public virtual void test_periodRate_badDates() { DiscountOvernightIndexRates test = DiscountOvernightIndexRates.of(GBP_SONIA, DFCURVE, SERIES); assertThrowsIllegalArg(() => test.periodRate(GBP_SONIA_AFTER_END, DATE_AFTER)); }