/** * 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 computation */ public static IborRateComputation of(IborIndex index, LocalDate fixingDate, ReferenceData refData) { return new IborRateComputation(IborIndexObservation.of(index, fixingDate, refData)); }
/** * Creates an instance from two indices and fixing date. * <p> * The indices may be passed in any order. * * @param index1 the first index * @param index2 the second index * @param fixingDate the fixing date * @param refData the reference data to use when resolving holiday calendars * @return the interpolated rate computation */ public static IborInterpolatedRateComputation of( IborIndex index1, IborIndex index2, LocalDate fixingDate, ReferenceData refData) { boolean inOrder = indicesInOrder(index1, index2, fixingDate); IborIndexObservation obs1 = IborIndexObservation.of(index1, fixingDate, refData); IborIndexObservation obs2 = IborIndexObservation.of(index2, fixingDate, refData); return new IborInterpolatedRateComputation(inOrder ? obs1 : obs2, inOrder ? obs2 : obs1); }
public void test_serialization() { IborIndexObservation test = IborIndexObservation.of(GBP_LIBOR_3M, date(2014, 6, 30), REF_DATA); assertSerialization(test); }
public void coverage() { IborRateSensitivity test = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, 32d); coverImmutableBean(test); IborRateSensitivity test2 = IborRateSensitivity.of( IborIndexObservation.of(USD_LIBOR_3M, DATE2, REF_DATA), USD, 16d); coverBeanEquals(test, test2); }
public void test_of() { IborRateComputation test = IborRateComputation.of(USD_LIBOR_3M, date(2016, 2, 18), REF_DATA); IborIndexObservation obs = IborIndexObservation.of(USD_LIBOR_3M, date(2016, 2, 18), REF_DATA); IborRateComputation expected = IborRateComputation.of(obs); assertEquals(test, expected); assertEquals(test.getCurrency(), USD); assertEquals(test.getIndex(), obs.getIndex()); assertEquals(test.getFixingDate(), obs.getFixingDate()); assertEquals(test.getEffectiveDate(), obs.getEffectiveDate()); assertEquals(test.getMaturityDate(), obs.getMaturityDate()); assertEquals(test.getYearFraction(), obs.getYearFraction()); }
public void test_compareKey() { ZeroRateSensitivity a1 = ZeroRateSensitivity.of(GBP, YEARFRAC, 32d); ZeroRateSensitivity a2 = ZeroRateSensitivity.of(GBP, YEARFRAC, 32d); ZeroRateSensitivity b = ZeroRateSensitivity.of(USD, YEARFRAC, 32d); ZeroRateSensitivity c = ZeroRateSensitivity.of(GBP, YEARFRAC2, 32d); IborRateSensitivity other = IborRateSensitivity.of(IborIndexObservation.of(GBP_LIBOR_3M, date(2014, 6, 30), REF_DATA), 32d); assertEquals(a1.compareKey(a2), 0); assertEquals(a1.compareKey(b) < 0, true); assertEquals(b.compareKey(a1) > 0, true); assertEquals(a1.compareKey(c) < 0, true); assertEquals(c.compareKey(a1) > 0, true); assertEquals(a1.compareKey(other) > 0, true); assertEquals(other.compareKey(a1) < 0, true); }
public void test_compareKey() { IborRateSensitivity a1 = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, 32d); IborRateSensitivity a2 = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, 32d); IborRateSensitivity b = IborRateSensitivity.of(IborIndexObservation.of(USD_LIBOR_3M, DATE2, REF_DATA), 32d); IborRateSensitivity c = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, USD, 32d); IborRateSensitivity d = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION2, 32d); ZeroRateSensitivity other = ZeroRateSensitivity.of(GBP, 2d, 32d); assertEquals(a1.compareKey(a2), 0); assertEquals(a1.compareKey(b) < 0, true); assertEquals(b.compareKey(a1) > 0, true); assertEquals(a1.compareKey(c) < 0, true); assertEquals(c.compareKey(a1) > 0, true); assertEquals(a1.compareKey(d) < 0, true); assertEquals(d.compareKey(a1) > 0, true); assertEquals(a1.compareKey(other) < 0, true); assertEquals(other.compareKey(a1) > 0, true); }
public void test_compareKey() { CreditCurveZeroRateSensitivity a1 = CreditCurveZeroRateSensitivity.of(LEGAL_ENTITY, GBP, YEAR_FRACTION, 32d); CreditCurveZeroRateSensitivity a2 = CreditCurveZeroRateSensitivity.of(LEGAL_ENTITY, GBP, YEAR_FRACTION, 32d); CreditCurveZeroRateSensitivity b = CreditCurveZeroRateSensitivity.of(LEGAL_ENTITY, GBP, 10d, 32d); CreditCurveZeroRateSensitivity c = CreditCurveZeroRateSensitivity.of(LEGAL_ENTITY, USD, YEAR_FRACTION, 32d); CreditCurveZeroRateSensitivity d = CreditCurveZeroRateSensitivity.of(LEGAL_ENTITY, USD, YEAR_FRACTION, GBP, 32d); IborRateSensitivity other = IborRateSensitivity.of(IborIndexObservation.of(GBP_LIBOR_3M, date(2014, 6, 30), REF_DATA), 32d); assertEquals(a1.compareKey(a2), 0); assertEquals(a1.compareKey(b) < 0, true); assertEquals(b.compareKey(a1) > 0, true); assertEquals(a1.compareKey(c) < 0, true); assertEquals(a1.compareKey(d) < 0, true); assertEquals(c.compareKey(a1) > 0, true); assertEquals(a1.compareKey(other) < 0, true); assertEquals(other.compareKey(a1) > 0, true); }
public void test_compareKey() { IssuerCurveZeroRateSensitivity a1 = IssuerCurveZeroRateSensitivity.of(CURRENCY, YEARFRAC, GROUP, VALUE); IssuerCurveZeroRateSensitivity a2 = IssuerCurveZeroRateSensitivity.of(CURRENCY, YEARFRAC, GROUP, VALUE); IssuerCurveZeroRateSensitivity b = IssuerCurveZeroRateSensitivity.of(GBP, YEARFRAC, GROUP, VALUE); IssuerCurveZeroRateSensitivity c = IssuerCurveZeroRateSensitivity.of(CURRENCY, YEARFRAC2, GROUP, VALUE); IssuerCurveZeroRateSensitivity d = IssuerCurveZeroRateSensitivity.of(CURRENCY, YEARFRAC, LegalEntityGroup.of("ISSUER2"), VALUE); IborRateSensitivity other = IborRateSensitivity.of( IborIndexObservation.of(GBP_LIBOR_3M, date(2015, 8, 27), REF_DATA), 32d); assertEquals(a1.compareKey(a2), 0); assertEquals(a1.compareKey(b) > 0, true); assertEquals(b.compareKey(a1) < 0, true); assertEquals(a1.compareKey(c) < 0, true); assertEquals(c.compareKey(a1) > 0, true); assertEquals(a1.compareKey(d) < 0, true); assertEquals(d.compareKey(a1) > 0, true); assertEquals(a1.compareKey(other) > 0, true); assertEquals(other.compareKey(a1) < 0, true); }
public void test_compareKey() { RepoCurveZeroRateSensitivity a1 = RepoCurveZeroRateSensitivity.of(CURRENCY, YEARFRAC, GROUP, VALUE); RepoCurveZeroRateSensitivity a2 = RepoCurveZeroRateSensitivity.of(CURRENCY, YEARFRAC, GROUP, VALUE); RepoCurveZeroRateSensitivity b = RepoCurveZeroRateSensitivity.of(GBP, YEARFRAC, GROUP, VALUE); RepoCurveZeroRateSensitivity c = RepoCurveZeroRateSensitivity.of(CURRENCY, YEARFRAC2, GROUP, VALUE); RepoCurveZeroRateSensitivity d = RepoCurveZeroRateSensitivity.of(CURRENCY, YEARFRAC, RepoGroup.of("ISSUER1 BND 3Y"), VALUE); IborRateSensitivity other = IborRateSensitivity.of(IborIndexObservation.of(GBP_LIBOR_3M, date(2014, 6, 30), REF_DATA), 32d); assertEquals(a1.compareKey(a2), 0); assertEquals(a1.compareKey(b) > 0, true); assertEquals(b.compareKey(a1) < 0, true); assertEquals(a1.compareKey(c) < 0, true); assertEquals(c.compareKey(a1) > 0, true); assertEquals(a1.compareKey(d) < 0, true); assertEquals(d.compareKey(a1) > 0, true); assertEquals(a1.compareKey(other) > 0, true); assertEquals(other.compareKey(a1) < 0, true); }
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); }
for (int i = 0; i < fixingDates.length; i++) { IborAveragedFixing fixing = IborAveragedFixing.builder() .observation(IborIndexObservation.of(GBP_LIBOR_3M, fixingDates[i], REF_DATA)) .weight(weights[i]) .build();
double discountFactor = Math.exp(-discountRate * paymentTime); LocalDate fixingDate = FRA_AFMA.getStartDate(); IborIndexObservation obs = IborIndexObservation.of(FRA.getIndex(), fixingDate, REF_DATA); PointSensitivityBuilder sens = IborRateSensitivity.of(obs, 1d); when(mockDf.discountFactor(fraExp.getPaymentDate()))
double discountFactor = Math.exp(-discountRate * paymentTime); LocalDate fixingDate = FRA_NONE.getStartDate(); IborIndexObservation obs = IborIndexObservation.of(FRA.getIndex(), fixingDate, REF_DATA); PointSensitivityBuilder sens = IborRateSensitivity.of(obs, 1d); when(mockDf.discountFactor(fraExp.getPaymentDate()))
double discountFactor = Math.exp(-discountRate * paymentTime); LocalDate fixingDate = FRA.getStartDate(); IborIndexObservation obs = IborIndexObservation.of(FRA.getIndex(), fixingDate, REF_DATA); PointSensitivityBuilder sens = IborRateSensitivity.of(obs, 1d); when(mockDf.discountFactor(fraExp.getPaymentDate()))
public void test_gbpLibor3m_dates() { IborIndex test = IborIndex.of("GBP-LIBOR-3M"); assertEquals(test.calculateEffectiveFromFixing(date(2014, 10, 13), REF_DATA), date(2014, 10, 13)); assertEquals(test.calculateMaturityFromFixing(date(2014, 10, 13), REF_DATA), date(2015, 1, 13)); assertEquals(test.calculateFixingFromEffective(date(2014, 10, 13), REF_DATA), date(2014, 10, 13)); assertEquals(test.calculateMaturityFromEffective(date(2014, 10, 13), REF_DATA), date(2015, 1, 13)); // weekend assertEquals(test.calculateEffectiveFromFixing(date(2014, 10, 10), REF_DATA), date(2014, 10, 10)); assertEquals(test.calculateMaturityFromFixing(date(2014, 10, 10), REF_DATA), date(2015, 1, 12)); assertEquals(test.calculateFixingFromEffective(date(2014, 10, 10), REF_DATA), date(2014, 10, 10)); assertEquals(test.calculateMaturityFromEffective(date(2014, 10, 10), REF_DATA), date(2015, 1, 12)); // input date is Sunday assertEquals(test.calculateEffectiveFromFixing(date(2014, 10, 12), REF_DATA), date(2014, 10, 13)); assertEquals(test.calculateMaturityFromFixing(date(2014, 10, 12), REF_DATA), date(2015, 1, 13)); assertEquals(test.calculateFixingFromEffective(date(2014, 10, 12), REF_DATA), date(2014, 10, 13)); assertEquals(test.calculateMaturityFromEffective(date(2014, 10, 12), REF_DATA), date(2015, 1, 13)); // fixing time and zone assertEquals(test.calculateFixingDateTime(date(2014, 10, 13)), date(2014, 10, 13).atTime(LocalTime.of(11, 0)).atZone(ZoneId.of("Europe/London"))); // resolve assertEquals(test.resolve(REF_DATA).apply(date(2014, 10, 13)), IborIndexObservation.of(test, date(2014, 10, 13), REF_DATA)); }
public void test_usdLibor3m_dates() { IborIndex test = IborIndex.of("USD-LIBOR-3M"); assertEquals(test.calculateEffectiveFromFixing(date(2014, 10, 27), REF_DATA), date(2014, 10, 29)); assertEquals(test.calculateMaturityFromFixing(date(2014, 10, 27), REF_DATA), date(2015, 1, 29)); assertEquals(test.calculateFixingFromEffective(date(2014, 10, 29), REF_DATA), date(2014, 10, 27)); assertEquals(test.calculateMaturityFromEffective(date(2014, 10, 29), REF_DATA), date(2015, 1, 29)); // weekend assertEquals(test.calculateEffectiveFromFixing(date(2014, 10, 10), REF_DATA), date(2014, 10, 14)); assertEquals(test.calculateMaturityFromFixing(date(2014, 10, 10), REF_DATA), date(2015, 1, 14)); assertEquals(test.calculateFixingFromEffective(date(2014, 10, 14), REF_DATA), date(2014, 10, 10)); assertEquals(test.calculateMaturityFromEffective(date(2014, 10, 14), REF_DATA), date(2015, 1, 14)); // effective date is US holiday assertEquals(test.calculateEffectiveFromFixing(date(2015, 1, 16), REF_DATA), date(2015, 1, 20)); assertEquals(test.calculateMaturityFromFixing(date(2015, 1, 16), REF_DATA), date(2015, 4, 20)); assertEquals(test.calculateFixingFromEffective(date(2015, 1, 20), REF_DATA), date(2015, 1, 16)); assertEquals(test.calculateMaturityFromEffective(date(2015, 1, 20), REF_DATA), date(2015, 4, 20)); // input date is Sunday, 13th is US holiday, but not UK holiday (can fix, but not be effective) assertEquals(test.calculateEffectiveFromFixing(date(2014, 10, 12), REF_DATA), date(2014, 10, 15)); assertEquals(test.calculateMaturityFromFixing(date(2014, 10, 12), REF_DATA), date(2015, 1, 15)); assertEquals(test.calculateFixingFromEffective(date(2014, 10, 12), REF_DATA), date(2014, 10, 10)); assertEquals(test.calculateMaturityFromEffective(date(2014, 10, 12), REF_DATA), date(2015, 1, 14)); // fixing time and zone assertEquals(test.calculateFixingDateTime(date(2014, 10, 13)), date(2014, 10, 13).atTime(LocalTime.of(11, 0)).atZone(ZoneId.of("Europe/London"))); // resolve assertEquals(test.resolve(REF_DATA).apply(date(2014, 10, 27)), IborIndexObservation.of(test, date(2014, 10, 27), REF_DATA)); }
.build(); IborIndexObservation obs1 = IborIndexObservation.of(GBP_LIBOR_3M, DATE_01_02, REF_DATA); IborIndexObservation obs2 = IborIndexObservation.of(GBP_LIBOR_3M, DATE_02_03, REF_DATA); IborIndexObservation obs3 = IborIndexObservation.of(GBP_LIBOR_3M, DATE_03_03, REF_DATA); ImmutableList<IborAveragedFixing> fixings1 = ImmutableList.of( IborAveragedFixing.ofDaysInResetPeriod(obs1, DATE_01_06, DATE_02_05, 0.028d), .build(); IborIndexObservation obs4 = IborIndexObservation.of(GBP_LIBOR_3M, DATE_04_03, REF_DATA); IborIndexObservation obs5 = IborIndexObservation.of(GBP_LIBOR_3M, DATE_05_01, REF_DATA); IborIndexObservation obs6 = IborIndexObservation.of(GBP_LIBOR_3M, DATE_06_03, REF_DATA); ImmutableList<IborAveragedFixing> fixings2 = ImmutableList.of( IborAveragedFixing.ofDaysInResetPeriod(obs4, DATE_04_07, DATE_05_06),
.rateComputation(FixedRateComputation.of(0.030d)) .build(); IborIndexObservation obs4 = IborIndexObservation.of(GBP_LIBOR_3M, DATE_04_03, REF_DATA); IborIndexObservation obs5 = IborIndexObservation.of(GBP_LIBOR_3M, DATE_05_01, REF_DATA); IborIndexObservation obs6 = IborIndexObservation.of(GBP_LIBOR_3M, DATE_06_03, REF_DATA); ImmutableList<IborAveragedFixing> fixings2 = ImmutableList.of( IborAveragedFixing.ofDaysInResetPeriod(obs4, DATE_04_07, DATE_05_06, 0.028d),