Esempio n. 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(dataProvider = "types") public void test_null(PeriodAdditionConvention type)
        public virtual void test_null(PeriodAdditionConvention type)
        {
            assertThrowsIllegalArg(() => type.adjust(null, Period.ofMonths(3), HolidayCalendars.NO_HOLIDAYS));
            assertThrowsIllegalArg(() => type.adjust(date(2014, 7, 11), null, HolidayCalendars.NO_HOLIDAYS));
            assertThrowsIllegalArg(() => type.adjust(date(2014, 7, 11), Period.ofMonths(3), null));
            assertThrowsIllegalArg(() => type.adjust(null, null, null));
        }
        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());
        }
 private PeriodAdjustment(Period period, PeriodAdditionConvention additionConvention, BusinessDayAdjustment adjustment)
 {
     JodaBeanUtils.notNull(period, "period");
     JodaBeanUtils.notNull(additionConvention, "additionConvention");
     JodaBeanUtils.notNull(adjustment, "adjustment");
     this.period             = period;
     this.additionConvention = additionConvention;
     this.adjustment         = adjustment;
     validate();
 }
 private TenorAdjustment(Tenor tenor, PeriodAdditionConvention additionConvention, BusinessDayAdjustment adjustment)
 {
     JodaBeanUtils.notNull(tenor, "tenor");
     JodaBeanUtils.notNull(additionConvention, "additionConvention");
     JodaBeanUtils.notNull(adjustment, "adjustment");
     this.tenor = tenor;
     this.additionConvention = additionConvention;
     this.adjustment         = adjustment;
     validate();
 }
            public override Builder set(string propertyName, object newValue)
            {
                switch (propertyName.GetHashCode())
                {
                case 110246592:         // tenor
                    this.tenor_Renamed = (Tenor)newValue;
                    break;

                case 1652975501:         // additionConvention
                    this.additionConvention_Renamed = (PeriodAdditionConvention)newValue;
                    break;

                case 1977085293:         // adjustment
                    this.adjustment_Renamed = (BusinessDayAdjustment)newValue;
                    break;

                default:
                    throw new NoSuchElementException("Unknown property: " + propertyName);
                }
                return(this);
            }
Esempio n. 6
0
 public virtual void test_of_lookup_null()
 {
     assertThrowsIllegalArg(() => PeriodAdditionConvention.of(null));
 }
Esempio n. 7
0
 public virtual void test_of_lookup_notFound()
 {
     assertThrowsIllegalArg(() => PeriodAdditionConvention.of("Rubbish"));
 }
Esempio n. 8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(dataProvider = "name") public void test_extendedEnum(PeriodAdditionConvention convention, String name)
        public virtual void test_extendedEnum(PeriodAdditionConvention convention, string name)
        {
            ImmutableMap <string, PeriodAdditionConvention> map = PeriodAdditionConvention.extendedEnum().lookupAll();

            assertEquals(map.get(name), convention);
        }
Esempio n. 9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(dataProvider = "name") public void test_of_lookup(PeriodAdditionConvention convention, String name)
        public virtual void test_of_lookup(PeriodAdditionConvention convention, string name)
        {
            assertEquals(PeriodAdditionConvention.of(name), convention);
        }
Esempio n. 10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(dataProvider = "name") public void test_toString(PeriodAdditionConvention convention, String name)
        public virtual void test_toString(PeriodAdditionConvention convention, string name)
        {
            assertEquals(convention.ToString(), name);
        }
Esempio n. 11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(dataProvider = "name") public void test_name(PeriodAdditionConvention convention, String name)
        public virtual void test_name(PeriodAdditionConvention convention, string name)
        {
            assertEquals(convention.Name, name);
        }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Obtains an instance that can adjust a date by the specified tenor.
 /// <para>
 /// When adjusting a date, the specified tenor is added to the input date.
 /// The business day adjustment will then be used to ensure the result is a valid business day.
 ///
 /// </para>
 /// </summary>
 /// <param name="tenor">  the tenor to add to the input date </param>
 /// <param name="additionConvention">  the convention used to perform the addition </param>
 /// <param name="adjustment">  the business day adjustment to apply to the result of the addition </param>
 /// <returns> the tenor adjustment </returns>
 public static TenorAdjustment of(Tenor tenor, PeriodAdditionConvention additionConvention, BusinessDayAdjustment adjustment)
 {
     return(new TenorAdjustment(tenor, additionConvention, adjustment));
 }
 /// <summary>
 /// Sets the addition convention to apply.
 /// <para>
 /// When the adjustment is performed, this convention is used to refine the adjusted date.
 /// The most common convention is to move the end date to the last business day of the month
 /// if the start date is the last business day of the month.
 /// </para>
 /// </summary>
 /// <param name="additionConvention">  the new value, not null </param>
 /// <returns> this, for chaining, not null </returns>
 public Builder additionConvention(PeriodAdditionConvention additionConvention)
 {
     JodaBeanUtils.notNull(additionConvention, "additionConvention");
     this.additionConvention_Renamed = additionConvention;
     return(this);
 }
 /// <summary>
 /// Restricted copy constructor. </summary>
 /// <param name="beanToCopy">  the bean to copy from, not null </param>
 internal Builder(TenorAdjustment beanToCopy)
 {
     this.tenor_Renamed = beanToCopy.Tenor;
     this.additionConvention_Renamed = beanToCopy.AdditionConvention;
     this.adjustment_Renamed         = beanToCopy.Adjustment;
 }
 /// <summary>
 /// Restricted copy constructor. </summary>
 /// <param name="beanToCopy">  the bean to copy from, not null </param>
 internal Builder(PeriodAdjustment beanToCopy)
 {
     this.period_Renamed             = beanToCopy.Period;
     this.additionConvention_Renamed = beanToCopy.AdditionConvention;
     this.adjustment_Renamed         = beanToCopy.Adjustment;
 }
 private static bool isEndOfMonth(PeriodAdditionConvention tenorConvention)
 {
     return(tenorConvention.Equals(PeriodAdditionConventions.LAST_BUSINESS_DAY) || tenorConvention.Equals(PeriodAdditionConventions.LAST_DAY));
 }
Esempio n. 17
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(dataProvider = "convention") public void test_convention(PeriodAdditionConvention convention, java.time.LocalDate input, int months, java.time.LocalDate expected)
        public virtual void test_convention(PeriodAdditionConvention convention, LocalDate input, int months, LocalDate expected)
        {
            assertEquals(convention.adjust(input, Period.ofMonths(months), HolidayCalendars.SAT_SUN), expected);
        }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Obtains an instance that can adjust a date by the specified period.
 /// <para>
 /// When adjusting a date, the specified period is added to the input date.
 /// The business day adjustment will then be used to ensure the result is a valid business day.
 ///
 /// </para>
 /// </summary>
 /// <param name="period">  the period to add to the input date </param>
 /// <param name="additionConvention">  the convention used to perform the addition </param>
 /// <param name="adjustment">  the business day adjustment to apply to the result of the addition </param>
 /// <returns> the period adjustment </returns>
 public static PeriodAdjustment of(Period period, PeriodAdditionConvention additionConvention, BusinessDayAdjustment adjustment)
 {
     return(new PeriodAdjustment(period, additionConvention, adjustment));
 }