@Override public IborIndexObservation build() { return new IborIndexObservation( index, fixingDate, effectiveDate, maturityDate, yearFraction); }
private IborIndexObservation create( LocalDate fixingDate, HolidayCalendar fixingCal, DateAdjuster effectiveAdjuster, DateAdjuster maturityAdjuster) { LocalDate fixingBusinessDay = fixingCal.nextOrSame(fixingDate); LocalDate effectiveDate = effectiveAdjuster.adjust(fixingBusinessDay); LocalDate maturityDate = maturityAdjuster.adjust(effectiveDate); double yearFraction = dayCount.yearFraction(effectiveDate, maturityDate); return new IborIndexObservation(this, fixingDate, effectiveDate, maturityDate, yearFraction); }
/** * Creates an instance from an index and fixing date. * <p> * The reference data is used to find the maturity date from the fixing date. * * @param index the index * @param fixingDate the fixing date * @param refData the reference data to use when resolving holiday calendars * @return the rate observation */ public static IborIndexObservation of( IborIndex index, LocalDate fixingDate, ReferenceData refData) { LocalDate effectiveDate = index.calculateEffectiveFromFixing(fixingDate, refData); LocalDate maturityDate = index.calculateMaturityFromEffective(effectiveDate, refData); double yearFraction = index.getDayCount().yearFraction(effectiveDate, maturityDate); return new IborIndexObservation(index, fixingDate, effectiveDate, maturityDate, yearFraction); }
public void test_of() { IborIndexObservation test = IborIndexObservation.of(USD_LIBOR_3M, date(2016, 2, 18), REF_DATA); double yearFraction = USD_LIBOR_3M.getDayCount().yearFraction(date(2016, 2, 22), date(2016, 5, 23)); IborIndexObservation expected = new IborIndexObservation( USD_LIBOR_3M, date(2016, 2, 18), date(2016, 2, 22), date(2016, 5, 23), yearFraction); assertEquals(test, expected); assertEquals(test.getCurrency(), USD); }