public void test_discountFactor_withSpread_smallYearFraction() { SimpleDiscountFactors test = SimpleDiscountFactors.of(GBP, DATE_VAL, CURVE); assertEquals(test.discountFactorWithSpread(DATE_VAL, SPREAD, PERIODIC, 2), 1d); }
public void test_discountFactor_withSpread_continuous() { SimpleDiscountFactors test = SimpleDiscountFactors.of(GBP, DATE_VAL, CURVE); double relativeYearFraction = ACT_365F.relativeYearFraction(DATE_VAL, DATE_AFTER); double expected = CURVE.yValue(relativeYearFraction) * Math.exp(-SPREAD * relativeYearFraction); assertEquals(test.discountFactorWithSpread(DATE_AFTER, SPREAD, CONTINUOUS, 0), expected, TOL); }
public void test_discountFactor_withSpread_periodic() { int periodPerYear = 4; SimpleDiscountFactors test = SimpleDiscountFactors.of(GBP, DATE_VAL, CURVE); double relativeYearFraction = ACT_365F.relativeYearFraction(DATE_VAL, DATE_AFTER); double discountFactorBase = test.discountFactor(DATE_AFTER); double rate = (Math.pow(discountFactorBase, -1d / periodPerYear / relativeYearFraction) - 1d) * periodPerYear; double expected = discountFactorFromPeriodicallyCompoundedRate(rate + SPREAD, periodPerYear, relativeYearFraction); assertEquals(test.discountFactorWithSpread(DATE_AFTER, SPREAD, PERIODIC, periodPerYear), expected, TOL); }