/**
  * Constructor from the details. The business day conventions, end-of-month and spot lag are from
  * the Ibor index.
  *
  * @param name The generator name. Not null.
  * @param fixedLegPeriod The fixed leg payment period.
  * @param fixedLegDayCount The day count convention associated to the fixed leg.
  * @param iborIndex The Ibor index of the floating leg.
  */
 public GeneratorSwapFixedIbor(
     String name, Period fixedLegPeriod, DayCount fixedLegDayCount, IborIndex iborIndex) {
   super(name);
   Validate.notNull(fixedLegPeriod, "fixed leg period");
   Validate.notNull(fixedLegDayCount, "fixed leg day count");
   Validate.notNull(iborIndex, "ibor index");
   _fixedLegPeriod = fixedLegPeriod;
   _fixedLegDayCount = fixedLegDayCount;
   _iborIndex = iborIndex;
   //    _name = iborIndex.getCurrency().toString() + iborIndex.getTenor().toString() +
   // fixedLegPeriod.toString();
   _businessDayConvention = iborIndex.getBusinessDayConvention();
   _endOfMonth = iborIndex.isEndOfMonth();
   _spotLag = iborIndex.getSpotLag();
 }
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = prime * result + _businessDayConvention.hashCode();
   result = prime * result + (_endOfMonth ? 1231 : 1237);
   result = prime * result + _fixedLegDayCount.hashCode();
   result = prime * result + _fixedLegPeriod.hashCode();
   result = prime * result + _iborIndex.hashCode();
   result = prime * result + getName().hashCode();
   result = prime * result + _spotLag;
   return result;
 }
Example #3
0
 public void test_gbpLibor3m_dates() {
   IborIndex test = IborIndex.of("GBP-LIBOR-3M");
   assertEquals(test.calculateEffectiveFromFixing(date(2014, 10, 13)), date(2014, 10, 13));
   assertEquals(test.calculateFixingFromEffective(date(2014, 10, 13)), date(2014, 10, 13));
   assertEquals(test.calculateMaturityFromEffective(date(2014, 10, 13)), date(2015, 1, 13));
   // weekend
   assertEquals(test.calculateEffectiveFromFixing(date(2014, 10, 10)), date(2014, 10, 10));
   assertEquals(test.calculateFixingFromEffective(date(2014, 10, 10)), date(2014, 10, 10));
   assertEquals(test.calculateMaturityFromEffective(date(2014, 10, 10)), date(2015, 1, 12));
   // input date is Sunday
   assertEquals(test.calculateEffectiveFromFixing(date(2014, 10, 12)), date(2014, 10, 13));
   assertEquals(test.calculateFixingFromEffective(date(2014, 10, 12)), date(2014, 10, 13));
   assertEquals(test.calculateMaturityFromEffective(date(2014, 10, 12)), date(2015, 1, 13));
 }
Example #4
0
 public void test_gbpLibor3m() {
   IborIndex test = IborIndex.of("GBP-LIBOR-3M");
   assertEquals(test.getCurrency(), GBP);
   assertEquals(test.getName(), "GBP-LIBOR-3M");
   assertEquals(test.getTenor(), TENOR_3M);
   assertEquals(test.getFixingCalendar(), GBLO);
   assertEquals(
       test.getFixingDateOffset(),
       DaysAdjustment.ofCalendarDays(0, BusinessDayAdjustment.of(PRECEDING, GBLO)));
   assertEquals(
       test.getEffectiveDateOffset(),
       DaysAdjustment.ofCalendarDays(0, BusinessDayAdjustment.of(FOLLOWING, GBLO)));
   assertEquals(
       test.getMaturityDateOffset(),
       TenorAdjustment.ofLastBusinessDay(
           TENOR_3M, BusinessDayAdjustment.of(MODIFIED_FOLLOWING, GBLO)));
   assertEquals(test.getDayCount(), ACT_365F);
   assertEquals(test.toString(), "GBP-LIBOR-3M");
 }
Example #5
0
 public void test_null() {
   IborIndex test = IborIndex.of("GBP-LIBOR-3M");
   assertThrowsIllegalArg(() -> test.calculateEffectiveFromFixing(null));
   assertThrowsIllegalArg(() -> test.calculateFixingFromEffective(null));
   assertThrowsIllegalArg(() -> test.calculateMaturityFromEffective(null));
 }
Example #6
0
 public void test_of_lookup_null() {
   assertThrowsIllegalArg(() -> IborIndex.of(null));
 }
Example #7
0
 public void test_of_lookup_notFound() {
   assertThrowsIllegalArg(() -> IborIndex.of("Rubbish"));
 }
Example #8
0
 @Test(dataProvider = "name")
 public void test_extendedEnum(IborIndex convention, String name) {
   ImmutableMap<String, IborIndex> map = IborIndex.extendedEnum().lookupAll();
   assertEquals(map.get(name), convention);
 }
 /**
  * Gets the generator calendar.
  *
  * @return The calendar.
  */
 public Calendar getCalendar() {
   return _iborIndex.getCalendar();
 }
Example #10
0
 @Test(dataProvider = "name")
 public void test_toString(IborIndex convention, String name) {
   assertEquals(convention.toString(), name);
 }
Example #11
0
 public void test_usdLibor_all() {
   assertEquals(IborIndex.of("USD-LIBOR-1W").getName(), "USD-LIBOR-1W");
   assertEquals(IborIndex.of("USD-LIBOR-1W"), IborIndices.USD_LIBOR_1W);
   assertEquals(IborIndex.of("USD-LIBOR-1M").getName(), "USD-LIBOR-1M");
   assertEquals(IborIndex.of("USD-LIBOR-1M"), IborIndices.USD_LIBOR_1M);
   assertEquals(IborIndex.of("USD-LIBOR-2M").getName(), "USD-LIBOR-2M");
   assertEquals(IborIndex.of("USD-LIBOR-2M"), IborIndices.USD_LIBOR_2M);
   assertEquals(IborIndex.of("USD-LIBOR-3M").getName(), "USD-LIBOR-3M");
   assertEquals(IborIndex.of("USD-LIBOR-3M"), IborIndices.USD_LIBOR_3M);
   assertEquals(IborIndex.of("USD-LIBOR-6M").getName(), "USD-LIBOR-6M");
   assertEquals(IborIndex.of("USD-LIBOR-6M"), IborIndices.USD_LIBOR_6M);
   assertEquals(IborIndex.of("USD-LIBOR-12M").getName(), "USD-LIBOR-12M");
   assertEquals(IborIndex.of("USD-LIBOR-12M"), IborIndices.USD_LIBOR_12M);
 }
Example #12
0
 public void test_euibor3m() {
   IborIndex test = IborIndex.of("EUR-EURIBOR-3M");
   assertEquals(test.getCurrency(), EUR);
   assertEquals(test.getName(), "EUR-EURIBOR-3M");
   assertEquals(test.getTenor(), TENOR_3M);
   assertEquals(test.getFixingCalendar(), EUTA);
   assertEquals(test.getFixingDateOffset(), DaysAdjustment.ofBusinessDays(-2, EUTA));
   assertEquals(test.getEffectiveDateOffset(), DaysAdjustment.ofBusinessDays(2, EUTA));
   assertEquals(
       test.getMaturityDateOffset(),
       TenorAdjustment.ofLastBusinessDay(
           TENOR_3M, BusinessDayAdjustment.of(MODIFIED_FOLLOWING, EUTA)));
   assertEquals(test.getDayCount(), ACT_360);
   assertEquals(test.toString(), "EUR-EURIBOR-3M");
 }
Example #13
0
 public void test_usdLibor3m_dates() {
   IborIndex test = IborIndex.of("USD-LIBOR-3M");
   assertEquals(test.calculateEffectiveFromFixing(date(2014, 10, 27)), date(2014, 10, 29));
   assertEquals(test.calculateFixingFromEffective(date(2014, 10, 29)), date(2014, 10, 27));
   assertEquals(test.calculateMaturityFromEffective(date(2014, 10, 29)), date(2015, 1, 29));
   // weekend
   assertEquals(test.calculateEffectiveFromFixing(date(2014, 10, 10)), date(2014, 10, 14));
   assertEquals(test.calculateFixingFromEffective(date(2014, 10, 14)), date(2014, 10, 10));
   assertEquals(test.calculateMaturityFromEffective(date(2014, 10, 14)), date(2015, 1, 14));
   // effective date is US holiday
   assertEquals(test.calculateEffectiveFromFixing(date(2015, 1, 16)), date(2015, 1, 20));
   assertEquals(test.calculateFixingFromEffective(date(2015, 1, 20)), date(2015, 1, 16));
   assertEquals(test.calculateMaturityFromEffective(date(2015, 1, 20)), 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)), date(2014, 10, 15));
   assertEquals(test.calculateFixingFromEffective(date(2014, 10, 12)), date(2014, 10, 10));
   assertEquals(test.calculateMaturityFromEffective(date(2014, 10, 12)), date(2015, 1, 14));
 }
Example #14
0
 public void test_usdLibor3m() {
   IborIndex test = IborIndex.of("USD-LIBOR-3M");
   assertEquals(test.getCurrency(), USD);
   assertEquals(test.getName(), "USD-LIBOR-3M");
   assertEquals(test.getTenor(), TENOR_3M);
   assertEquals(test.getFixingCalendar(), GBLO);
   assertEquals(test.getFixingDateOffset(), DaysAdjustment.ofBusinessDays(-2, GBLO));
   assertEquals(
       test.getEffectiveDateOffset(),
       DaysAdjustment.ofBusinessDays(
           2, GBLO, BusinessDayAdjustment.of(FOLLOWING, GBLO.combineWith(USNY))));
   assertEquals(
       test.getMaturityDateOffset(),
       TenorAdjustment.ofLastBusinessDay(
           TENOR_3M, BusinessDayAdjustment.of(MODIFIED_FOLLOWING, GBLO.combineWith(USNY))));
   assertEquals(test.getDayCount(), ACT_360);
   assertEquals(test.toString(), "USD-LIBOR-3M");
 }
Example #15
0
 @Test(dataProvider = "name")
 public void test_of_lookup(IborIndex convention, String name) {
   assertEquals(IborIndex.of(name), convention);
 }
Example #16
0
 /**
  * Checks and returns an Ibor index.
  *
  * <p>If this is an Ibor index, then this returns the matching {@link IborIndex}. If not, an
  * exception is thrown.
  *
  * @param tenor the tenor of the index
  * @return the index
  * @throws IllegalStateException if the type is not an Ibor index type
  * @see #getType()
  */
 public IborIndex toIborIndex(Tenor tenor) {
   if (!type.isIbor()) {
     throw new IllegalStateException("Incorrect index type, expected Ibor: " + name);
   }
   return IborIndex.of(indexName + tenor.normalized().toString());
 }
 /**
  * Gets the generator currency.
  *
  * @return The currency.
  */
 public Currency getCurrency() {
   return _iborIndex.getCurrency();
 }