switch (getType()) { case IBOR: { Set<Tenor> tenors = getTenors(); if (tenors.contains(Tenor.TENOR_3M)) { return Tenor.TENOR_3M;
/** * Checks and returns the fixing offset associated with the Ibor index. * <p> * If this name represents an Ibor index, then this method returns the associated fixing offset. * If not, an exception is thrown. * <p> * This method exists primarily to handle DKK CIBOR, where there are two floating rate names but * only one underlying index. The CIBOR index itself has a convention where the fixing date is 2 days * before the reset date and the effective date is 2 days after the fixing date, matching the name "DKK-CIBOR2-DKNA13". * The alternative name, "DKK-CIBOR-DKNA13", has the fixing date equal to the reset date, but with * the effective date two days later. * * @return the fixing offset applicable to the index * @throws IllegalStateException if the type is not an Ibor index type */ public default DaysAdjustment toIborIndexFixingOffset() { return toIborIndex(Iterables.getFirst(getTenors(), Tenor.TENOR_3M)).getFixingDateOffset(); }
public void test_overnightIndex() { assertEquals(FloatingRateName.of("GBP-WMBA-SONIA-COMPOUND").getDefaultTenor(), Tenor.TENOR_1D); assertEquals(FloatingRateName.of("GBP-WMBA-SONIA-COMPOUND").toFloatingRateIndex(), OvernightIndices.GBP_SONIA); assertEquals(FloatingRateName.of("GBP-WMBA-SONIA-COMPOUND").toFloatingRateIndex(Tenor.TENOR_1M), OvernightIndices.GBP_SONIA); assertEquals(FloatingRateName.of("GBP-WMBA-SONIA-COMPOUND").toOvernightIndex(), OvernightIndices.GBP_SONIA); assertEquals(FloatingRateNames.USD_FED_FUND.toOvernightIndex(), OvernightIndices.USD_FED_FUND); assertEquals(FloatingRateNames.USD_FED_FUND_AVG.toOvernightIndex(), OvernightIndices.USD_FED_FUND); assertThrows(() -> FloatingRateName.of("GBP-LIBOR-BBA").toOvernightIndex(), IllegalStateException.class); assertEquals(FloatingRateName.of("GBP-WMBA-SONIA-COMPOUND").getTenors(), ImmutableSet.of()); assertThrows(() -> FloatingRateName.of("GBP-WMBA-SONIA-COMPOUND").toIborIndexFixingOffset(), IllegalStateException.class); }
public void test_priceIndex() { assertEquals(FloatingRateName.of("UK-HICP").getDefaultTenor(), Tenor.TENOR_1Y); assertEquals(FloatingRateName.of("UK-HICP").toFloatingRateIndex(), PriceIndices.GB_HICP); assertEquals(FloatingRateName.of("UK-HICP").toFloatingRateIndex(Tenor.TENOR_1M), PriceIndices.GB_HICP); assertEquals(FloatingRateName.of("UK-HICP").toPriceIndex(), PriceIndices.GB_HICP); assertThrows(() -> FloatingRateName.of("GBP-LIBOR-BBA").toPriceIndex(), IllegalStateException.class); assertEquals(FloatingRateName.of("UK-HICP").getTenors(), ImmutableSet.of()); assertThrows(() -> FloatingRateName.of("UK-HICP").toIborIndexFixingOffset(), IllegalStateException.class); }
public void test_iborIndex_tenor() { assertEquals(FloatingRateName.of("GBP-LIBOR-BBA").getDefaultTenor(), Tenor.TENOR_3M); assertEquals(FloatingRateName.of("GBP-LIBOR-BBA").toFloatingRateIndex(), IborIndices.GBP_LIBOR_3M); assertEquals(FloatingRateName.of("GBP-LIBOR-BBA").toFloatingRateIndex(Tenor.TENOR_1M), IborIndices.GBP_LIBOR_1M); assertEquals(FloatingRateName.of("GBP-LIBOR-BBA").toIborIndex(Tenor.TENOR_6M), IborIndices.GBP_LIBOR_6M); assertEquals(FloatingRateName.of("GBP-LIBOR-BBA").toIborIndex(Tenor.TENOR_12M), IborIndices.GBP_LIBOR_12M); assertEquals(FloatingRateName.of("GBP-LIBOR-BBA").toIborIndex(Tenor.TENOR_1Y), IborIndices.GBP_LIBOR_12M); assertThrows(() -> FloatingRateName.of("GBP-WMBA-SONIA-COMPOUND").toIborIndex(Tenor.TENOR_6M), IllegalStateException.class); assertEquals( ImmutableList.copyOf(FloatingRateName.of("GBP-LIBOR-BBA").getTenors()), ImmutableList.of(Tenor.TENOR_1W, Tenor.TENOR_1M, Tenor.TENOR_2M, Tenor.TENOR_3M, Tenor.TENOR_6M, Tenor.TENOR_12M)); assertEquals( FloatingRateName.of("GBP-LIBOR-BBA").toIborIndexFixingOffset(), DaysAdjustment.ofCalendarDays(0, BusinessDayAdjustment.of(PRECEDING, GBLO))); }