YieldAndDiscountCurveUtils { public static double forwardRateFromCurve(final YieldAndDiscountCurve curve, final ZonedDateTime curveDate, final ZonedDateTime fixingDate, final IborIndex index, final Calendar cal) { ArgumentChecker.notNull(curve, "curve"); ArgumentChecker.notNull(curveDate, "curveDate"); ArgumentChecker.notNull(fixingDate, "fixingDate"); ArgumentChecker.notNull(index, "iborIndex"); ArgumentChecker.notNull(cal, "calendar"); final ZonedDateTime fixingPeriodStartDate = ScheduleCalculator.getAdjustedDate(fixingDate, index.getSpotLag(), cal); final double fixingPeriodStartTime = TimeCalculator.getTimeBetween(curveDate, fixingPeriodStartDate); final ZonedDateTime fixingPeriodEndDate = ScheduleCalculator.getAdjustedDate(fixingDate, index, cal); final double fixingPeriodEndTime = TimeCalculator.getTimeBetween(curveDate, fixingPeriodEndDate); final double accrualFixing = index.getDayCount().getDayCountFraction(fixingPeriodStartDate, fixingPeriodEndDate); final double dfStart = curve.getDiscountFactor(fixingPeriodStartTime); final double dfEnd = curve.getDiscountFactor(fixingPeriodEndTime); final double forwardRate = (dfStart / dfEnd - 1.0d) / accrualFixing; return forwardRate; }  static double forwardRateFromCurve(final YieldAndDiscountCurve curve, final ZonedDateTime curveDate, final ZonedDateTime fixingDate, final IborIndex index, final Calendar cal); static double forwardRateFromProvider(final MulticurveProviderInterface multicurve, final ZonedDateTime curveDate, final ZonedDateTime fixingDate,
      final IborIndex index, final Calendar cal); static double zeroCouponRate(final YieldAndDiscountCurve curve, final ZonedDateTime curveDate, final ZonedDateTime payDate, final DayCount dc, final int paymentPerYear); static double discountFactor(final YieldAndDiscountCurve curve, final ZonedDateTime curveDate, final ZonedDateTime payDate);  }
@Test public void forwardRateCurveTest() { final YieldAndDiscountCurve curve3M = MULTICURVE.getCurve(USDLIBOR3M); final ZonedDateTime fixingDate = DateUtils.getUTCDate(2013, 10, 28); final ZonedDateTime fixingPeriodStartDate = ScheduleCalculator.getAdjustedDate(fixingDate, USDLIBOR6M.getSpotLag(), NYC); final double fixingPeriodStartTime = TimeCalculator.getTimeBetween(CURVE_DATE, fixingPeriodStartDate); final ZonedDateTime fixingPeriodEndDate = ScheduleCalculator.getAdjustedDate(fixingDate, USDLIBOR6M, NYC); final double fixingPeriodEndTime = TimeCalculator.getTimeBetween(CURVE_DATE, fixingPeriodEndDate); final double accrualFixing = USDLIBOR6M.getDayCount().getDayCountFraction(fixingPeriodStartDate, fixingPeriodEndDate); final double dfStart = curve3M.getDiscountFactor(fixingPeriodStartTime); final double dfEnd = curve3M.getDiscountFactor(fixingPeriodEndTime); final double forwardExpected = (dfStart / dfEnd - 1.0d) / accrualFixing; final double forwardComputedCurve = YieldAndDiscountCurveUtils.forwardRateFromCurve(curve3M, CURVE_DATE, fixingDate, USDLIBOR6M, NYC); assertEquals("forwardRateCurve", forwardExpected, forwardComputedCurve, TOLERANCE_RATE); }