示例#1
0
        //-------------------------------------------------------------------------
        public virtual void test_equals()
        {
            ImmutableIborIndex a = ImmutableIborIndex.builder().name("Test-3M").currency(Currency.GBP).fixingCalendar(GBLO).fixingDateOffset(DaysAdjustment.ofBusinessDays(-2, GBLO)).effectiveDateOffset(DaysAdjustment.ofBusinessDays(2, GBLO)).maturityDateOffset(TenorAdjustment.ofLastBusinessDay(TENOR_3M, BusinessDayAdjustment.NONE)).dayCount(ACT_360).fixingTime(LocalTime.NOON).fixingZone(ZoneId.of("Europe/London")).build();
            IborIndex          b = a.toBuilder().name("Rubbish-3M").build();

            assertEquals(a.Equals(b), false);
        }
示例#2
0
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            ImmutableIborIndex index = ImmutableIborIndex.builder().name("Test-3M").currency(Currency.GBP).fixingCalendar(GBLO).fixingDateOffset(DaysAdjustment.ofBusinessDays(-2, GBLO)).effectiveDateOffset(DaysAdjustment.ofBusinessDays(2, GBLO)).maturityDateOffset(TenorAdjustment.ofLastBusinessDay(TENOR_3M, BusinessDayAdjustment.NONE)).dayCount(ACT_360).fixingTime(LocalTime.NOON).fixingZone(ZoneId.of("Europe/London")).build();

            coverImmutableBean(index);
            coverPrivateConstructor(typeof(IborIndices));
        }
        private static IborIndex parseIborIndex(CsvRow row)
        {
            string            name      = row.getValue(NAME_FIELD);
            Currency          currency  = Currency.parse(row.getValue(CURRENCY_FIELD));
            bool              active    = bool.Parse(row.getValue(ACTIVE_FIELD));
            DayCount          dayCount  = DayCount.of(row.getValue(DAY_COUNT_FIELD));
            HolidayCalendarId fixingCal = HolidayCalendarId.of(row.getValue(FIXING_CALENDAR_FIELD));
            int offsetDays = int.Parse(row.getValue(OFFSET_DAYS_FIELD));
            HolidayCalendarId offsetCal        = HolidayCalendarId.of(row.getValue(OFFSET_CALENDAR_FIELD));
            HolidayCalendarId effectiveCal     = HolidayCalendarId.of(row.getValue(EFFECTIVE_DATE_CALENDAR_FIELD));
            Tenor             tenor            = Tenor.parse(row.getValue(TENOR_FIELD));
            LocalTime         time             = LocalTime.parse(row.getValue(FIXING_TIME_FIELD), TIME_FORMAT);
            ZoneId            zoneId           = ZoneId.of(row.getValue(FIXING_ZONE_FIELD));
            DayCount          fixedLegDayCount = DayCount.of(row.getValue(FIXED_LEG_DAY_COUNT));

            // interpret CSV
            DaysAdjustment fixingOffset    = DaysAdjustment.ofBusinessDays(-offsetDays, offsetCal, BusinessDayAdjustment.of(PRECEDING, fixingCal)).normalized();
            DaysAdjustment effectiveOffset = DaysAdjustment.ofBusinessDays(offsetDays, offsetCal, BusinessDayAdjustment.of(FOLLOWING, effectiveCal)).normalized();

            // convention can be two different things
            PeriodAdditionConvention periodAdditionConvention = PeriodAdditionConvention.extendedEnum().find(row.getField(TENOR_CONVENTION_FIELD)).orElse(PeriodAdditionConventions.NONE);
            BusinessDayConvention    tenorBusinessConvention  = BusinessDayConvention.extendedEnum().find(row.getField(TENOR_CONVENTION_FIELD)).orElse(isEndOfMonth(periodAdditionConvention) ? MODIFIED_FOLLOWING : FOLLOWING);
            BusinessDayAdjustment    adj             = BusinessDayAdjustment.of(tenorBusinessConvention, effectiveCal);
            TenorAdjustment          tenorAdjustment = TenorAdjustment.of(tenor, periodAdditionConvention, adj);

            // build result
            return(ImmutableIborIndex.builder().name(name).currency(currency).active(active).dayCount(dayCount).fixingCalendar(fixingCal).fixingDateOffset(fixingOffset).effectiveDateOffset(effectiveOffset).maturityDateOffset(tenorAdjustment).fixingTime(time).fixingZone(zoneId).defaultFixedLegDayCount(fixedLegDayCount).build());
        }
示例#4
0
        public virtual void test_serialization()
        {
            IborIndex index = ImmutableIborIndex.builder().name("Test-3M").currency(Currency.GBP).fixingCalendar(GBLO).fixingDateOffset(DaysAdjustment.ofBusinessDays(-2, GBLO)).effectiveDateOffset(DaysAdjustment.ofBusinessDays(2, GBLO)).maturityDateOffset(TenorAdjustment.ofLastBusinessDay(TENOR_3M, BusinessDayAdjustment.NONE)).dayCount(ACT_360).fixingTime(LocalTime.NOON).fixingZone(ZoneId.of("Europe/London")).build();

            assertSerialization(index);
        }