YieldAndDiscountCurve implements InterestRateModel<Double>, Serializable { public double getDiscountFactor(final double t) { if (t == 0) { return 1.0; } return Math.exp(-t * getInterestRate(t)); } YieldAndDiscountCurve(final String name); String getName(); double getDiscountFactor(final double t); abstract double getForwardRate(final double t); double getPeriodicInterestRate(final double t, final int compoundingPeriodsPerYear); abstract double[] getInterestRateParameterSensitivity(final double time); abstract int getNumberOfParameters(); abstract List<String> getUnderlyingCurvesNames(); int getNumberOfIntrinsicParameters(final Set<String> curvesNames); @Deprecated YieldAndDiscountCurve withParallelShift(final double shift); YieldAndDiscountCurve withSingleShift(final double t, final double shift);  }
@Test public void testGetters() { assertEquals(YIELD.getCurve(), R); assertEquals(YIELD.getInterestRate(1.4), R.getYValue(1.4), 1e-15); assertEquals(YIELD.getDiscountFactor(1.5), Math.exp(-1.5 * R.getYValue(1.5)), 1e-15); assertEquals(DISCOUNT.getInterestRate(1.4), -Math.log(DF.getYValue(1.4)) / 1.4, 1e-15); assertEquals(DISCOUNT.getDiscountFactor(1.5), DF.getYValue(1.5), 1e-15); }