/** * 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_cibor() { assertEquals(FloatingRateName.of("DKK-CIBOR-DKNA13").getDefaultTenor(), Tenor.TENOR_3M); assertEquals(FloatingRateName.of("DKK-CIBOR-DKNA13").toFloatingRateIndex(), IborIndices.DKK_CIBOR_3M); assertEquals(FloatingRateName.of("DKK-CIBOR-DKNA13").toFloatingRateIndex(Tenor.TENOR_1M), IborIndices.DKK_CIBOR_1M); assertEquals(FloatingRateName.of("DKK-CIBOR-DKNA13").toIborIndex(Tenor.TENOR_6M), IborIndices.DKK_CIBOR_6M); assertEquals(FloatingRateName.of("DKK-CIBOR2-DKNA13").toIborIndex(Tenor.TENOR_6M), IborIndices.DKK_CIBOR_6M); assertEquals( FloatingRateName.of("DKK-CIBOR-DKNA13").toIborIndexFixingOffset(), DaysAdjustment.ofCalendarDays(0, BusinessDayAdjustment.of(PRECEDING, DKCO))); assertEquals( FloatingRateName.of("DKK-CIBOR2-DKNA13").toIborIndexFixingOffset(), DaysAdjustment.ofBusinessDays(-2, DKCO)); }
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))); }
/** * Converts an FpML 'FloatingRateIndex' with multiple tenors to an {@code Index}. * * @param baseEl the FpML floating rate index element to parse * @return the index * @throws RuntimeException if unable to parse */ public List<Index> parseIndexes(XmlElement baseEl) { XmlElement indexEl = baseEl.getChild("floatingRateIndex"); validateScheme(indexEl, "floatingRateIndexScheme", "http://www.fpml.org/coding-scheme/floating-rate-index"); FloatingRateName floatingName = FloatingRateName.of(indexEl.getContent()); List<XmlElement> tenorEls = baseEl.getChildren("indexTenor"); if (tenorEls.isEmpty()) { return ImmutableList.of(floatingName.toOvernightIndex()); } else { return tenorEls.stream() .map(el -> floatingName.toIborIndex(parseIndexTenor(el))) .collect(toImmutableList()); } }
public void test_tiee() { assertEquals(FloatingRateName.of("MXN-TIIE").getDefaultTenor(), Tenor.TENOR_13W); assertEquals(FloatingRateName.of("MXN-TIIE").toFloatingRateIndex(), IborIndices.MXN_TIIE_13W); assertEquals(FloatingRateName.of("MXN-TIIE").toFloatingRateIndex(Tenor.TENOR_4W), IborIndices.MXN_TIIE_4W); assertEquals(FloatingRateName.of("MXN-TIIE").toIborIndex(Tenor.TENOR_4W), IborIndices.MXN_TIIE_4W); assertEquals(FloatingRateName.of("MXN-TIIE").toIborIndexFixingOffset(), DaysAdjustment.ofBusinessDays(-1, MXMC)); }
/** * Returns a floating rate index. * <p> * Returns a {@link FloatingRateIndex} for this rate name. * Only Ibor, Overnight and Price indices are handled. * If the rate name is an Ibor rate, the specified tenor is used. * * @param iborTenor the tenor to use if this rate is Ibor * @return the index * @throws IllegalArgumentException if unable to return an index, which should * only happen if the system is not configured correctly */ public default FloatingRateIndex toFloatingRateIndex(Tenor iborTenor) { switch (getType()) { case IBOR: return toIborIndex(iborTenor); case OVERNIGHT_COMPOUNDED: case OVERNIGHT_AVERAGED: return toOvernightIndex(); case PRICE: return toPriceIndex(); default: throw new IllegalArgumentException("Floating rate index type not known: " + getType()); } }
/** * Returns a floating rate index. * <p> * Returns a {@link FloatingRateIndex} for this rate name. * Only Ibor, Overnight and Price indices are handled. * If the rate name is an Ibor rate, the {@linkplain #getDefaultTenor() default tenor} is used. * * @return the index * @throws IllegalArgumentException if unable to return an index, which should * only happen if the system is not configured correctly */ public default FloatingRateIndex toFloatingRateIndex() { // code copied to avoid calling getDefaultTenor() unless necessary switch (getType()) { case IBOR: return toIborIndex(getDefaultTenor()); case OVERNIGHT_COMPOUNDED: case OVERNIGHT_AVERAGED: return toOvernightIndex(); case PRICE: return toPriceIndex(); default: throw new IllegalArgumentException("Floating rate index type not known: " + getType()); } }