/// <summary>
        /// Gets the adjusted calculation period start dates.
        /// </summary>
        /// <param name="effectiveDate">The effective date.</param>
        /// <param name="terminationDate">The termination date.</param>
        /// <param name="periodInterval">The period interval.</param>
        /// <param name="rollConvention">The roll convention.</param>
        /// <param name="firstRegularPeriodDate">The first regular period date.</param>
        /// <param name="stubPeriodType">Type of the stub period.</param>
        /// <param name="businessCalendar">The businessCalendar.</param>
        /// <param name="businessDayConvention">The business day convention.</param>
        /// <returns>A vertical range of dates.</returns>
        public static DateTime[] GetAdjustedCalculationPeriodDates(DateTime effectiveDate, DateTime terminationDate,
                                                                   string periodInterval, string rollConvention, DateTime firstRegularPeriodDate, string stubPeriodType,
                                                                   IBusinessCalendar businessCalendar, string businessDayConvention)
        {
            const string       dateToReturn = "unadjustedStartDate";
            StubPeriodTypeEnum?stubType     = null;

            if (!string.IsNullOrEmpty(stubPeriodType))
            {
                stubType = (StubPeriodTypeEnum)Enum.Parse(typeof(StubPeriodTypeEnum), stubPeriodType, true);
            }
            var periods  = CalculationPeriodHelper.GenerateUnadjustedCalculationDates(effectiveDate, terminationDate, firstRegularPeriodDate, PeriodHelper.Parse(periodInterval), RollConventionEnumHelper.Parse(rollConvention), stubType);
            var dates    = CalculationPeriodHelper.GetCalculationPeriodsProperty <DateTime>(periods, dateToReturn);
            var newDates = new DateTime[dates.Count];
            var index    = 0;

            foreach (var date in dates)
            {
                var newDate = BusinessCalendarHelper.Advance(businessCalendar, date, "Calendar", "0D", businessDayConvention);
                newDates[index] = newDate;
                index++;
            }
            var result = newDates;

            return(result);
        }
Exemplo n.º 2
0
        public string CreateCalendar(Excel.Range propertiesRange, Excel.Range dateArray)
        {
            var properties = propertiesRange.Value[System.Reflection.Missing.Value] as object[, ];

            properties = (object[, ])DataRangeHelper.TrimNulls(properties);
            var namedValueSet = properties.ToNamedValueSet();
            var dates         = DataRangeHelper.StripDateTimeRange(dateArray);
            var identifier    = namedValueSet.GetValue <string>("UniqueIdentifier", true);
            var calendar      = BusinessCalendarHelper.CreateCalendar(namedValueSet, dates);

            Engine.Cache.SaveObject(calendar, NameSpace + "." + identifier, namedValueSet);
            Engine.Logger.LogDebug("Loaded business center holiday dates: {0}", identifier);
            return(identifier);
        }