示例#1
0
        public void UnadjustedDatesFromTermination()
        {
            DateTime           effectiveDate     = new DateTime(2009, 05, 01);
            DateTime           terminationDate   = new DateTime(2010, 11, 27);
            Period             periodInterval    = PeriodHelper.Parse("3M");
            RollConventionEnum rollDayConvention = RollConventionEnum.Item19;

            DateTime firstRegularPeriodStartDate = effectiveDate;
            DateTime lastRegularPeriodEndDate    = terminationDate;

            DateTime[] dates = DateScheduler.GetUnadjustedDatesFromTerminationDate(effectiveDate, terminationDate, periodInterval, rollDayConvention, out firstRegularPeriodStartDate, out lastRegularPeriodEndDate);

            Assert.AreEqual(dates.Length, 7);
            Assert.AreEqual(firstRegularPeriodStartDate, new DateTime(2009, 08, 19));
            Assert.AreEqual(lastRegularPeriodEndDate, new DateTime(2010, 08, 19));

            dates = DateScheduler.GetUnadjustedDatesFromTerminationDate(effectiveDate, terminationDate, periodInterval, rollDayConvention, out firstRegularPeriodStartDate, out lastRegularPeriodEndDate);
            Assert.AreEqual(dates.Length, 7);
            Assert.AreEqual(firstRegularPeriodStartDate, new DateTime(2009, 08, 19));
            Assert.AreEqual(lastRegularPeriodEndDate, new DateTime(2010, 08, 19));

            effectiveDate     = new DateTime(2009, 11, 16);
            terminationDate   = new DateTime(2011, 11, 28);
            rollDayConvention = RollConventionEnum.Item29;
            dates             = DateScheduler.GetUnadjustedDatesFromTerminationDate(effectiveDate, terminationDate, periodInterval, rollDayConvention, out firstRegularPeriodStartDate, out lastRegularPeriodEndDate);

            Assert.AreEqual(dates.Length, 9);
            Assert.AreEqual(firstRegularPeriodStartDate, new DateTime(2010, 02, 28));
            Assert.AreEqual(lastRegularPeriodEndDate, new DateTime(2011, 08, 29));
        }
示例#2
0
        /// <summary>
        /// Applies the roll convention to date.
        /// </summary>
        /// <param name="rollConvention">The roll convention.</param>
        /// <param name="referenceDate">The reference date.</param>
        /// <returns></returns>
        public static DateTime ApplyRollConventionToDate(RollConventionEnum rollConvention, DateTime referenceDate)
        {
            int result             = 0;
            int daysInRefDateMonth = DateTime.DaysInMonth(referenceDate.Year, referenceDate.Month);

            if (rollConvention >= RollConventionEnum.Item1 && rollConvention <= RollConventionEnum.Item30)
            {
                int.TryParse(rollConvention.ToString().Replace("Item", string.Empty), out result);
            }
            else if (rollConvention == RollConventionEnum.EOM)
            {
                result = daysInRefDateMonth;
            }
            else if (rollConvention == RollConventionEnum.NONE)
            {
                result = referenceDate.Day;
            }
            if (result == 0)
            {
                throw new ArgumentOutOfRangeException(nameof(rollConvention), rollConvention, "supplied value is not supported.");
            }
            if (result > daysInRefDateMonth)
            {
                result = daysInRefDateMonth;
            }
            return(new DateTime(referenceDate.Year, referenceDate.Month, result));
        }
示例#3
0
        public static DateTime AdjustDate(RollConventionEnum rollConvention, DateTime inputDate)
        {
            if (rollConvention == RollConventionEnum.NONE)
            {
                return(inputDate);
            }
            if (rollConvention == RollConventionEnum.EOM)
            {
                int currentMonth = inputDate.Month;
                while (currentMonth == inputDate.Month)
                {
                    inputDate = inputDate.AddDays(1);
                }
                return(inputDate.AddDays(-1));
            }
            if (rollConvention >= RollConventionEnum.Item1 && rollConvention <= RollConventionEnum.Item28)
            {
                int day = (rollConvention - RollConventionEnum.Item1) + 1;
                return(new DateTime(inputDate.Year, inputDate.Month, day));
            }
            if (rollConvention > RollConventionEnum.Item28 && rollConvention <= RollConventionEnum.Item30)
            {
                int day = (rollConvention - RollConventionEnum.Item1) + 1;

                if (inputDate.Month == 2)//This is a check to make sure that a valid February date is created.
                {
                    var startDate = new DateTime(inputDate.Year, inputDate.Month, 1).Date;
                    var endDate   = new DateTime(inputDate.Year, inputDate.Month + 1, 1).Date;
                    var days      = (endDate - startDate).Days;
                    return(new DateTime(inputDate.Year, inputDate.Month, System.Math.Min(day, days)));
                }
                return(new DateTime(inputDate.Year, inputDate.Month, day));
            }
            throw new ArgumentOutOfRangeException(nameof(rollConvention), rollConvention, "supplied value is not supported.");
        }
示例#4
0
        public void GetUnadjustedDates3Forward()
        {
            DateTime startDate = new DateTime(2008, 04, 10);
            DateTime endDate = new DateTime(2009, 04, 24);

            //Period interval = IntervalHelper.FromMonths(3);
            RollConventionEnum rollConventionEnum = RollConventionEnumHelper.Parse(startDate.Day.ToString());

            List<MetaScheduleItem> rollsMetaSchedule = new List<MetaScheduleItem>();

            MetaScheduleItem item1 = new MetaScheduleItem();
            item1.Period = IntervalHelper.FromMonths(6);
            item1.RollFrequency = IntervalHelper.FromMonths(1);
            item1.RollConvention = rollConventionEnum;
            rollsMetaSchedule.Add(item1);

            MetaScheduleItem item2 = new MetaScheduleItem();
            item2.Period = IntervalHelper.FromMonths(6);
            item2.RollFrequency = IntervalHelper.FromMonths(3);
            item2.RollConvention = rollConventionEnum;
            rollsMetaSchedule.Add(item2);

            List<DateTime> unadjustedDates = DatesMetaSchedule.GetUnadjustedDates3(startDate, endDate, rollsMetaSchedule, false);

            Debug.Print("Meta schedule:");
            //         Debug.Print(ParameterFormatter.FormatObject(ObjectToArrayOfPropertiesConverter.ConvertListToHorizontalArrayRange(rollsMetaSchedule)));

            Debug.Print("Start date: {0}", startDate);
            Debug.Print("End date: {0}", endDate);

            Debug.Print("Schedule:");
            PrintListOfDates(unadjustedDates);
        }
 public CalculationPeriodFrequency(XmlNode xmlNode)
 : base(xmlNode)
 {
     XmlNodeList rollConventionNodeList = xmlNode.SelectNodes("rollConvention");
     if (rollConventionNodeList.Count > 1 )
     {
             throw new Exception();
     }
     
     foreach (XmlNode item in rollConventionNodeList)
     {
         if (item.Attributes["href"] != null || item.Attributes["id"] == null) 
         {
             if (item.Attributes["id"] != null) 
             {
                 rollConventionIDRef = item.Attributes["id"].Name;
                 RollConventionEnum ob = RollConventionEnum();
                 IDManager.SetID(rollConventionIDRef, ob);
             }
             else if (item.Attributes.ToString() == "href")
             {
                 rollConventionIDRef = item.Attributes["href"].Name;
             }
             else
             {
                 rollConvention = new RollConventionEnum(item);
             }
         }
     }
     
 
 }
 /// <summary>
 /// Gets the unadjusted calculation date schedule from term date.
 /// </summary>
 /// <param name="effectiveDate">The effective date.</param>
 /// <param name="terminationDate">The termination date.</param>
 /// <param name="periodInterval">The period interval.</param>
 /// <param name="lastRegularPeriodEndDate">The last regular period end date.</param>
 /// <param name="rollConvention">The roll convention.</param>
 /// <param name="stubPeriodType">Type of the stub period.</param>
 /// <returns></returns>
 public List <CalculationPeriod> GetUnadjustedCalculationDateScheduleFromTermDate(DateTime effectiveDate, DateTime terminationDate, Period periodInterval, DateTime lastRegularPeriodEndDate, RollConventionEnum rollConvention, StubPeriodTypeEnum?stubPeriodType)
 {
     CalculationPeriodDates = null;
     PeriodInterval         = periodInterval;
     _effectiveDate         = effectiveDate;
     _termDate      = terminationDate;
     RollConvention = rollConvention;
     _unadjustedDateScheduleList = CalculationPeriodHelper.GenerateUnadjustedCalculationDatesFromTermDate(effectiveDate, terminationDate, periodInterval, lastRegularPeriodEndDate, rollConvention, stubPeriodType);
     return(_unadjustedDateScheduleList);
 }
示例#7
0
        /// <summary>
        /// Gets the first regular period start date.
        /// </summary>
        /// <param name="periodInterval">The period interval.</param>
        /// <param name="rollConvention">The roll convention.</param>
        /// <param name="startDate">The start date.</param>
        /// <returns></returns>
        public static DateTime GetFirstRegularPeriodStartDate(Period periodInterval, RollConventionEnum rollConvention, DateTime startDate)
        {
            DateTime advDate = periodInterval.Add(startDate);
            DateTime regularPeriodStartDate = advDate;

            if (rollConvention != RollConventionEnum.NONE)
            {
                regularPeriodStartDate = RollConventionEnumHelper.AdjustDate(rollConvention, advDate);
            }
            return(regularPeriodStartDate);
        }
示例#8
0
        public void GetUnadjustedDates2Forward()
        {
            DateTime startDate = new DateTime(2008, 04, 10);
            DateTime endDate = new DateTime(2009, 04, 24);

            Period interval = IntervalHelper.FromMonths(3);
            RollConventionEnum rollConventionEnum = RollConventionEnumHelper.Parse(startDate.Day.ToString());

            List<DateTime> unadjustedDates = DatesMetaSchedule.GetUnadjustedDates2(startDate, endDate, interval, rollConventionEnum, false);

            PrintListOfDates(unadjustedDates);
        }
        public void LongFinalStubSpecifiedButNoStub()
        {
            DateTime                   startDate       = new DateTime(2007, 01, 5);
            DateTime                   endDate         = new DateTime(2012, 01, 5);
            RollConventionEnum         rollConvention  = RollConventionEnum.Item5;
            CalculationPeriodFrequency periodFrequency = CalculationPeriodFrequencyHelper.Parse("3M", rollConvention.ToString());
            CalculationPeriodSchedule  cps             = new CalculationPeriodSchedule();
            Period periodInterval = CalculationPeriodHelper.CalculationPeriodFrequencyToInterval(periodFrequency);
            List <CalculationPeriod> unadjustedCalcPeriods = cps.GetUnadjustedCalculationDateSchedule(startDate, endDate, periodInterval, rollConvention, StubPeriodTypeEnum.LongFinal);

            Assert.AreEqual(unadjustedCalcPeriods.Count, 20);
            Assert.IsFalse(cps.HasFinalStub);
            Assert.IsFalse(cps.HasInitialStub);
        }
示例#10
0
        public void LongInitialStubSpecified()
        {
            DateTime                   startDate              = new DateTime(2007, 01, 5);
            DateTime                   endDate                = new DateTime(2012, 01, 5);
            RollConventionEnum         rollConvention         = RollConventionEnum.Item26;
            CalculationPeriodFrequency periodFrequency        = CalculationPeriodFrequencyHelper.Parse("3M", rollConvention.ToString());
            DateTime                   firstRegularPeriodDate = new DateTime(2007, 4, 26);
            CalculationPeriodSchedule  cps = new CalculationPeriodSchedule();
            List <CalculationPeriod>   unadjustedCalcPeriods = cps.GetUnadjustedCalculationDateSchedule(startDate, endDate, firstRegularPeriodDate, periodFrequency, StubPeriodTypeEnum.LongInitial);

            Assert.AreEqual(unadjustedCalcPeriods.Count, 20);
            Assert.IsTrue(cps.HasFinalStub);
            Assert.IsTrue(cps.HasInitialStub);
            Assert.IsTrue(CalculationPeriodHelper.IsLongStub(unadjustedCalcPeriods[0], cps.PeriodInterval));
        }
示例#11
0
        public void ShortFinalStubSpecifiedFromTermination()
        {
            DateTime                   startDate       = new DateTime(2007, 01, 5);
            DateTime                   endDate         = new DateTime(2010, 01, 5);
            RollConventionEnum         rollConvention  = RollConventionEnum.Item12;
            CalculationPeriodFrequency periodFrequency = CalculationPeriodFrequencyHelper.Parse("3M", rollConvention.ToString());
            Period periodInterval             = CalculationPeriodHelper.CalculationPeriodFrequencyToInterval(periodFrequency);
            CalculationPeriodSchedule cps     = new CalculationPeriodSchedule();
            DateTime lastRegularPeriodEndDate = new DateTime(2009, 8, 12);
            List <CalculationPeriod> unadjustedCalcPeriods = cps.GetUnadjustedCalculationDateScheduleFromTermDate(startDate, endDate, periodInterval, lastRegularPeriodEndDate, rollConvention, StubPeriodTypeEnum.ShortFinal);

            Assert.AreEqual(unadjustedCalcPeriods.Count, 13);
            Assert.IsTrue(cps.HasFinalStub);
            Assert.IsTrue(cps.HasInitialStub);
            Assert.IsTrue(CalculationPeriodHelper.IsShortStub(unadjustedCalcPeriods[unadjustedCalcPeriods.Count - 1], cps.PeriodInterval));
        }
示例#12
0
        public void RegularPeriodFrequencyUnadjustedDates()
        {
            // 5 year 3 month cash flow
            DateTime startDate = new DateTime(2007, 01, 5);

            RollConventionEnum rollConvention = RollConventionEnum.Item26;

            CalculationPeriodFrequency frequencyToMaturity = CalculationPeriodFrequencyHelper.Parse("5Y", rollConvention.ToString());
            CalculationPeriodFrequency periodFrequency     = CalculationPeriodFrequencyHelper.Parse("3M", rollConvention.ToString());
            CalculationPeriodSchedule  cps = new CalculationPeriodSchedule();
            List <CalculationPeriod>   unadjustedCalcPeriods = cps.GetUnadjustedCalculationDateSchedule(startDate, frequencyToMaturity, periodFrequency);
            List <DateTime>            dates = CalculationPeriodHelper.GetCalculationPeriodsProperty <DateTime>(unadjustedCalcPeriods, "unadjustedStartDate");

            Assert.AreEqual(unadjustedCalcPeriods.Count, 20);
            Assert.IsFalse(cps.HasInitialStub);
            Assert.IsFalse(cps.HasFinalStub);
        }
示例#13
0
        ///<summary>
        ///</summary>
        ///<param name="termsRange"></param>
        ///<param name="metaScheduleDefinitionRange"></param>
        ///<param name="paymentCalendar"></param>
        ///<returns></returns>
        public static List <AmortisingResultItem> GenerateCashflowSchedule(BillsSwapPricer2TermsRange termsRange,
                                                                           List <MetaScheduleRangeItem> metaScheduleDefinitionRange, IBusinessCalendar paymentCalendar)
        {
            RollConventionEnum     rollConventionEnum     = RollConventionEnumHelper.Parse(termsRange.RollDay);
            BusinessDayAdjustments businessDayAdjustments = BusinessDayAdjustmentsHelper.Create(termsRange.DateRollConvention, termsRange.Calendar);
            bool            backwardGeneration            = (termsRange.BuildDates.ToLower() == "backward");
            List <DateTime> adjustedDatesResult;
            List <DateTime> unadjustedDatesResult;

            if (termsRange.RollFrequency.ToLower().Contains("custom"))
            {
                var rollsMetaSchedule = metaScheduleDefinitionRange.Select(item => new MetaScheduleItem
                {
                    RollFrequency = PeriodHelper.Parse(item.RollFrequency), Period = PeriodHelper.Parse(item.Period), RollConvention = RollConventionEnumHelper.Parse(item.RollConvention)
                }).ToList();
                unadjustedDatesResult = DatesMetaSchedule.GetUnadjustedDates3(termsRange.StartDate, termsRange.EndDate,
                                                                              rollsMetaSchedule, backwardGeneration);
                adjustedDatesResult = AdjustedDatesMetaSchedule.GetAdjustedDates3(termsRange.StartDate, termsRange.EndDate,
                                                                                  rollsMetaSchedule, backwardGeneration, businessDayAdjustments, paymentCalendar);
            }
            else
            {
                Period interval = PeriodHelper.Parse(termsRange.RollFrequency);
                unadjustedDatesResult = DatesMetaSchedule.GetUnadjustedDates2(termsRange.StartDate, termsRange.EndDate,
                                                                              interval, rollConventionEnum, backwardGeneration);
                adjustedDatesResult = AdjustedDatesMetaSchedule.GetAdjustedDates2(termsRange.StartDate, termsRange.EndDate,
                                                                                  interval, rollConventionEnum, backwardGeneration, businessDayAdjustments, paymentCalendar);
            }
            var result = new List <AmortisingResultItem>();

            for (int i = 0; i < adjustedDatesResult.Count; i++)
            {
                DateTime adjustedTime         = adjustedDatesResult[i];
                DateTime unadjustedTime       = unadjustedDatesResult[i];
                var      amortisingResultItem = new AmortisingResultItem
                {
                    WasRolled        = (adjustedTime == unadjustedTime) ? "No" : "Yes",
                    RollDate         = adjustedTime,
                    AmortisingAmount = 0,
                    OutstandingValue = termsRange.FaceValue
                };
                result.Add(amortisingResultItem);
            }
            return(result);
        }
示例#14
0
        /// <summary>
        /// Gets the last regular period end date.
        /// </summary>
        /// <param name="periodInterval">The period interval.</param>
        /// <param name="rollConvention">The roll convention.</param>
        /// <param name="endDate">The end date.</param>
        /// <returns></returns>
        public static DateTime GetLastRegularPeriodEndDate(Period periodInterval, RollConventionEnum rollConvention, DateTime endDate)
        {
            int periodMultiplierAsInt = int.Parse(periodInterval.periodMultiplier);

            if (periodMultiplierAsInt > 0)
            {
                periodMultiplierAsInt = periodMultiplierAsInt * -1;
            }
            periodInterval.periodMultiplier = periodMultiplierAsInt.ToString(CultureInfo.InvariantCulture);
            DateTime advDate = periodInterval.Add(endDate);
            DateTime regularPeriodEndDate = advDate;

            if (rollConvention != RollConventionEnum.NONE)
            {
                regularPeriodEndDate = RollConventionEnumHelper.AdjustDate(rollConvention, advDate);
            }
            return(regularPeriodEndDate);
        }
示例#15
0
        public void UnadjustedDatesSchedule2()
        {
            DateTime           effectiveDate     = new DateTime(2008, 07, 9);
            DateTime           terminationDate   = new DateTime(2011, 07, 11);
            Period             periodInterval    = PeriodHelper.Parse("3M");
            RollConventionEnum rollDayConvention = RollConventionEnum.Item7;

            DateTime firstRegularPeriodStartDate = effectiveDate;
            DateTime lastRegularPeriodEndDate    = terminationDate;

            //Back|Forward are same
            string expectedDates = "9/07/2008;7/10/2008;7/01/2009;7/04/2009;7/07/2009;7/10/2009;7/01/2010;7/04/2010;7/07/2010;7/10/2010;7/01/2011;7/04/2011;11/07/2011";

            DateTime[] bdates = DateScheduler.GetUnadjustedDatesFromTerminationDate(effectiveDate, terminationDate, periodInterval, rollDayConvention, out firstRegularPeriodStartDate, out lastRegularPeriodEndDate);
            //bdates = AdjustDates(bdates, BusinessDayConventionEnum.MODFOLLOWING, "AUSY");
            Validate(expectedDates, bdates);

            DateTime[] fdates = DateScheduler.GetUnadjustedDatesFromEffectiveDate(effectiveDate, terminationDate, periodInterval, rollDayConvention, out firstRegularPeriodStartDate, out lastRegularPeriodEndDate);
            //fdates = AdjustDates(fdates, BusinessDayConventionEnum.MODFOLLOWING, "AUSY");
            Validate(expectedDates, fdates);
        }
示例#16
0
        /// <summary>
        /// Returns a list of unadjusted dates produced by a simple date scheduler.
        /// </summary>
        /// <param name="startDate"></param>
        /// <param name="endDate"></param>
        /// <param name="interval"></param>
        /// <param name="rollConventionEnum"></param>
        /// <param name="backwardGeneration"></param>
        /// <returns></returns>
        public static List <DateTime> GetUnadjustedDates2(DateTime startDate, DateTime endDate,
                                                          Period interval, RollConventionEnum rollConventionEnum,
                                                          bool backwardGeneration)
        {
            var results             = new List <DateTime>();
            var monthsInTheInterval = interval.GetPeriodMultiplier();

            if (backwardGeneration)//from end date to start date
            {
                var rollDate = endDate;
                while (rollDate > startDate)
                {
                    results.Add(rollDate);
                    var nextRollDate = rollDate.AddMonths(-monthsInTheInterval);
                    // roll adjust
                    //
                    var rollDateRollConventionAdjusted = RollConventionEnumHelper.AdjustDate(rollConventionEnum, nextRollDate);
                    rollDate = rollDateRollConventionAdjusted;
                }
                results.Add(startDate);
                results.Reverse();
            }
            else//from start date to end date.
            {
                var rollDate = startDate;
                while (rollDate < endDate)
                {
                    results.Add(rollDate);
                    var nextRollDate = rollDate.AddMonths(monthsInTheInterval);
                    // roll adjust
                    //
                    var rollDateRollConventionAdjusted = RollConventionEnumHelper.AdjustDate(rollConventionEnum, nextRollDate);
                    rollDate = rollDateRollConventionAdjusted;
                }
                results.Add(endDate);
            }
            return(RemoveDuplicates(results));
        }
        /// <summary>
        /// A simple date scheduler.
        /// </summary>
        /// <param name="startDate"></param>
        /// <param name="endDate"></param>
        /// <param name="interval"></param>
        /// <param name="rollConventionEnum"></param>
        /// <param name="backwardGeneration"></param>
        /// <param name="businessDayAdjustments"></param>
        /// <param name="businessCalendar"></param>
        /// <returns></returns>
        public static List <DateTime> GetAdjustedDates2(DateTime startDate, DateTime endDate, Period interval, RollConventionEnum rollConventionEnum,
                                                        bool backwardGeneration, BusinessDayAdjustments businessDayAdjustments, IBusinessCalendar businessCalendar)
        {
            var unadjustedDates = DatesMetaSchedule.GetUnadjustedDates2(startDate, endDate, interval, rollConventionEnum, backwardGeneration);

            return(unadjustedDates.Select(date => AdjustedDateHelper.ToAdjustedDate(businessCalendar, date, businessDayAdjustments)).ToList());
        }
示例#18
0
        ///<summary>
        ///</summary>
        ///<param name="directionDateGeneration"></param>
        ///<param name="effectiveDate"></param>
        ///<param name="terminationDate"></param>
        ///<param name="periodInterval"></param>
        ///<param name="rollDayConvention"></param>
        ///<returns></returns>
        ///<exception cref="ArgumentOutOfRangeException"></exception>
        public static DateTime[] GetUnadjustedDates(int directionDateGeneration, DateTime effectiveDate, DateTime terminationDate, Period periodInterval, RollConventionEnum rollDayConvention)
        {
            DateTime firstRegularPeriodStartDate;
            DateTime lastRegularPeriodEndDate;

            switch (directionDateGeneration)
            {
            case 1:
            {
                var result =
                    new List <DateTime>(GetUnadjustedDatesFromEffectiveDate(effectiveDate,
                                                                            terminationDate,
                                                                            periodInterval,
                                                                            rollDayConvention,
                                                                            out
                                                                            firstRegularPeriodStartDate,
                                                                            out
                                                                            lastRegularPeriodEndDate));

                //  remove extra(faulty-generated) date from the end if a swap is shorter than a period
                //
                if (periodInterval.Add(effectiveDate) > terminationDate)
                {
                    result.RemoveAt(result.Count - 1);         //remove last element
                }
                // if there is a long stub at the back
                //
                if (result[0] != lastRegularPeriodEndDate &&
                    periodInterval.Add(lastRegularPeriodEndDate) < result[result.Count - 1])         //
                {
                    //  it it is  long - make it short
                    //
                    DateTime realLastRegularPeriodEndDate = periodInterval.Add(lastRegularPeriodEndDate);

                    result.Insert(result.Count - 1, realLastRegularPeriodEndDate);
                }
                return(result.ToArray());
            }

            case 2:
            {
                var result =
                    new List <DateTime>(GetUnadjustedDatesFromTerminationDate(effectiveDate,
                                                                              terminationDate,
                                                                              periodInterval,
                                                                              rollDayConvention,
                                                                              out
                                                                              firstRegularPeriodStartDate,
                                                                              out
                                                                              lastRegularPeriodEndDate));

                // if there is a long stub at the front
                //
                if (result[0] != firstRegularPeriodStartDate &&
                    periodInterval.Subtract(firstRegularPeriodStartDate) > result[0])
                // add a check if a period is short ...
                {
                    //  it it is long - make it short
                    //
                    DateTime realFirstRegularPeriodStartDate = periodInterval.Subtract(firstRegularPeriodStartDate);

                    result.Insert(1, realFirstRegularPeriodStartDate);
                }
                return(result.ToArray());
            }

            default:
            {
                const string message =
                    "Argument value is out of range. Only 1 and 2 are the valid values for this argument";

                throw new ArgumentOutOfRangeException(nameof(directionDateGeneration), directionDateGeneration,
                                                      message);
            }
            }
        }
示例#19
0
        /// <summary>
        /// Gets the unadjusted dates.
        /// </summary>
        /// <param name="metaScheduleDefinition">The meta schedule definition.</param>
        /// <param name="startDate">The start date.</param>
        /// <param name="endDate">The end date.</param>
        /// <param name="defaultInterval">The default interval.</param>
        /// <param name="defaultRollConvention">The default roll convention.</param>
        /// <param name="fromStartDate">if set to <c>true</c> [from start date].</param>
        /// <returns></returns>
        public static DateTime[] GetUnadjustedDates
            (List <Triplet <Period, Period, RollConventionEnum> > metaScheduleDefinition
            , DateTime startDate
            , DateTime endDate
            , Period defaultInterval
            , RollConventionEnum defaultRollConvention
            , Boolean fromStartDate
            )
        {
            DateTime        firstReg;
            DateTime        lastReg;
            var             result = new List <DateTime>();
            List <DateTime> additionalDates;
            DateTime        fromDate           = startDate;
            DateTime        toDate             = endDate;
            int             intervalMulitplier = 1;

            if (!fromStartDate)
            {
                fromDate           = endDate;
                toDate             = startDate;
                intervalMulitplier = intervalMulitplier * -1;
            }
            var offsetsFromStartDateForRollPeriods = new List <Pair <Period, RollConventionEnum> >();

            foreach (var metaScheduleEntry in metaScheduleDefinition)
            {
                var numberOfRolls = (int)IntervalHelper.Div(metaScheduleEntry.Second, metaScheduleEntry.First);
                if (numberOfRolls == 0)
                {
                    throw new System.Exception("Invalid period interval specified. The period interval is greater than the duration interval");
                }
                if (!fromStartDate)
                {
                    metaScheduleEntry.First.periodMultiplier = (Convert.ToInt32(metaScheduleEntry.First.periodMultiplier) * intervalMulitplier).ToString(CultureInfo.InvariantCulture);
                }
                while (numberOfRolls-- > 0)
                {
                    offsetsFromStartDateForRollPeriods.Add(new Pair <Period, RollConventionEnum>(metaScheduleEntry.First, metaScheduleEntry.Third));
                }
            }
            if (offsetsFromStartDateForRollPeriods.Count > 0)
            {
                //  Generates dates from a list of intervals expressed as offsets.
                DateTime referenceDate = fromDate;
                foreach (var offset in offsetsFromStartDateForRollPeriods)
                {
                    if (referenceDate == fromDate)
                    {
                        result.Add(fromDate);
                    }
                    DateTime rollDateUnadjusted = offset.First.Add(referenceDate);
                    DateTime rollConventionDate = DateScheduler.ApplyRollConventionToDate(offset.Second, rollDateUnadjusted);
                    if ((fromStartDate && rollConventionDate > toDate) || (!fromStartDate && rollConventionDate < toDate))
                    {
                        result.Add(toDate);
                        break;
                    }
                    result.Add(rollConventionDate);
                    referenceDate = rollDateUnadjusted;
                }
                // if end date falls after the meta data schedule provided use the defaults
                if (result.Count > 0)
                {
                    if ((fromStartDate && result[result.Count - 1] < toDate) || (!fromStartDate && result[result.Count - 1] > toDate))
                    {
                        if (result[result.Count - 1] < endDate)
                        {
                            additionalDates = fromStartDate ? new List <DateTime>(DateScheduler.GetUnadjustedDatesFromEffectiveDate(result[result.Count - 1], toDate, defaultInterval, defaultRollConvention, out firstReg, out lastReg)) : new List <DateTime>(DateScheduler.GetUnadjustedDatesFromTerminationDate(toDate, result[result.Count - 1], defaultInterval, defaultRollConvention, out firstReg, out lastReg));
                            result.AddRange(additionalDates);
                            result.Sort();
                        }
                    }
                }
            }
            else
            {
                additionalDates = fromStartDate ? new List <DateTime>(DateScheduler.GetUnadjustedDatesFromEffectiveDate(startDate, toDate, defaultInterval, defaultRollConvention, out firstReg, out lastReg)) : new List <DateTime>(DateScheduler.GetUnadjustedDatesFromTerminationDate(startDate, toDate, defaultInterval, defaultRollConvention, out firstReg, out lastReg));
                result.AddRange(additionalDates);
            }
            result = RemoveDuplicates(result);
            result.Sort();
            return(result.ToArray());
        }
示例#20
0
        /// <summary>
        /// Generates the unadjusted calculation dates from term date.
        /// </summary>
        /// <param name="effectiveDate">The effective date.</param>
        /// <param name="terminationDate">The termination date.</param>
        /// <param name="periodInterval">The period interval.</param>
        /// <param name="lastRegularPeriodEndDate">The last regular period end date.</param>
        /// <param name="rollConvention">The roll convention.</param>
        /// <param name="stubPeriodType">Type of the stub period.</param>
        /// <returns></returns>
        static public List <CalculationPeriod> GenerateUnadjustedCalculationDatesFromTermDate(DateTime effectiveDate, DateTime terminationDate, Period periodInterval, DateTime lastRegularPeriodEndDate, RollConventionEnum rollConvention, StubPeriodTypeEnum?stubPeriodType)
        {
            var      unadjustedPeriodDates      = new List <CalculationPeriod>();
            DateTime lastRegularPeriodStartDate = AddPeriod(lastRegularPeriodEndDate, periodInterval, -1);

            if (lastRegularPeriodStartDate > effectiveDate)
            {
                Boolean bHasIrregularInitial;
                List <CalculationPeriod> regularPeriods = GetBackwardRegularPeriods(lastRegularPeriodStartDate, effectiveDate, periodInterval, rollConvention, out bHasIrregularInitial);

                if (regularPeriods.Count > 0)
                {
                    DateTime firstRegularPeriodStartDate = regularPeriods[0].unadjustedStartDate;
                    unadjustedPeriodDates = GenerateUnadjustedCalculationDates(effectiveDate, terminationDate, firstRegularPeriodStartDate, periodInterval, rollConvention, stubPeriodType);
                }
            }
            return(unadjustedPeriodDates);
        }
示例#21
0
 public static bool IsAdjusted(RollConventionEnum rollConvention, DateTime inputDate)
 {
     return(AdjustDate(rollConvention, inputDate) == inputDate);
 }
示例#22
0
        /// <summary>
        /// Generates the unadjusted calculation dates.
        /// </summary>
        /// <param name="effectiveDate">The effective date.</param>
        /// <param name="intervalToTerminationDate">The interval to termination date.</param>
        /// <param name="periodInterval">The period interval.</param>
        /// <param name="rollConvention">The roll convention.</param>
        /// <returns></returns>
        static public List <CalculationPeriod> GenerateUnadjustedCalculationDates(DateTime effectiveDate, Period intervalToTerminationDate, Period periodInterval, RollConventionEnum rollConvention)
        {
            DateTime startDate = effectiveDate;

            // Adjust the effective date
            if (rollConvention != RollConventionEnum.NONE)
            {
                startDate = RollConventionEnumHelper.AdjustDate(rollConvention, effectiveDate);
            }

            Double divisor = IntervalHelper.Div(intervalToTerminationDate, periodInterval);

            // The divisor has to be a whole number (i.e. the period must roll to the term date interval
            if ((divisor % 1) != 0)
            {
                throw new ArithmeticException("The period frequency will not roll to the supplied termination date interval");
            }

            DateTime           terminationDate = intervalToTerminationDate.Add(startDate);
            StubPeriodTypeEnum?stubPeriodType  = null;

            return(GenerateUnadjustedCalculationDates(startDate, terminationDate, effectiveDate, periodInterval, rollConvention, stubPeriodType));
        }
示例#23
0
        /// <summary>
        /// Generates the unadjusted calculation 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="intervalToFirstRegularPeriodStartDate">The interval to first regular period start date.</param>
        /// <param name="rollConvention">The roll convention.</param>
        /// <param name="stubPeriodType">Type of the stub period.</param>
        /// <returns></returns>
        static public List <CalculationPeriod> GenerateUnadjustedCalculationDates(DateTime effectiveDate, DateTime terminationDate, Period periodInterval, Period intervalToFirstRegularPeriodStartDate, RollConventionEnum rollConvention, StubPeriodTypeEnum?stubPeriodType)
        {
            DateTime firstRegularPeriodStartDate = GetFirstRegularPeriodStartDate(intervalToFirstRegularPeriodStartDate, rollConvention, effectiveDate);

            return(GenerateUnadjustedCalculationDates(effectiveDate, terminationDate, firstRegularPeriodStartDate, periodInterval, rollConvention, stubPeriodType));
        }
示例#24
0
        /// <summary>
        /// Generates the unadjusted calculation dates.
        /// </summary>
        /// <param name="effectiveDate">The effective date.</param>
        /// <param name="terminationDate">The termination date.</param>
        /// <param name="regularPeriodStartDate">The regular period start date.</param>
        /// <param name="periodInterval">The period interval.</param>
        /// <param name="rollConvention">The roll convention.</param>
        /// <param name="stubPeriodType">Type of the stub period.</param>
        /// <returns></returns>
        static public List <CalculationPeriod> GenerateUnadjustedCalculationDates(DateTime effectiveDate, DateTime terminationDate, DateTime regularPeriodStartDate, Period periodInterval, RollConventionEnum rollConvention, StubPeriodTypeEnum?stubPeriodType)
        {
            DateTime startDate = effectiveDate;
            DateTime endDate   = terminationDate;

            Boolean bContainsIrregularFinalPeriod;
            List <CalculationPeriod> forwardRegularPeriods = GetForwardRegularPeriods(regularPeriodStartDate, endDate, periodInterval, rollConvention, out bContainsIrregularFinalPeriod);

            if (bContainsIrregularFinalPeriod)
            {
                if (forwardRegularPeriods.Count == 0)
                {
                    CalculationPeriod calculationPeriod = CreateUnadjustedCalculationPeriod(regularPeriodStartDate, endDate);
                    forwardRegularPeriods.Add(calculationPeriod);
                }
                else
                {
                    forwardRegularPeriods = SetFinalIrregularStubPeriod(forwardRegularPeriods, endDate, stubPeriodType ?? StubPeriodTypeEnum.LongFinal);
                }
            }

            var backwardRegularPeriods = new List <CalculationPeriod>();

            if (regularPeriodStartDate > startDate)
            {
                var     irregularInitialStubType = StubPeriodTypeEnum.ShortInitial;
                Boolean bContainsIrregularInitialPeriod;
                backwardRegularPeriods = GetBackwardRegularPeriods(regularPeriodStartDate, startDate, periodInterval, rollConvention, out bContainsIrregularInitialPeriod);
                if ((bContainsIrregularInitialPeriod && stubPeriodType != null) && (stubPeriodType != StubPeriodTypeEnum.ShortInitial && stubPeriodType != StubPeriodTypeEnum.LongInitial))
                {
                    DateTime normalPeriodStart = AddPeriod(startDate, periodInterval, 1);
                    if (regularPeriodStartDate > normalPeriodStart)
                    {
                        irregularInitialStubType = StubPeriodTypeEnum.LongInitial;
                    }
                }
                else if ((bContainsIrregularInitialPeriod && stubPeriodType != null) && (stubPeriodType == StubPeriodTypeEnum.ShortInitial || stubPeriodType == StubPeriodTypeEnum.LongInitial))
                {
                    irregularInitialStubType = (StubPeriodTypeEnum)stubPeriodType;
                }

                if (bContainsIrregularInitialPeriod)
                {
                    if (backwardRegularPeriods.Count == 0)
                    {
                        CalculationPeriod calculationPeriod = CreateUnadjustedCalculationPeriod(startDate, regularPeriodStartDate);
                        backwardRegularPeriods.Add(calculationPeriod);
                    }
                    else
                    {
                        backwardRegularPeriods = SetInitialIrregularStubPeriod(backwardRegularPeriods, startDate, irregularInitialStubType);
                    }
                }
            }
            return(MergeCalculationPeriods(backwardRegularPeriods, forwardRegularPeriods));
        }
示例#25
0
        /// <summary>
        /// Gets the backward regular periods.
        /// </summary>
        /// <param name="startDate">The start date.</param>
        /// <param name="endDate">The end date.</param>
        /// <param name="periodInterval">The period interval.</param>
        /// <param name="rollConvention">The roll convention.</param>
        /// <param name="hasIrregularPeriod">if set to <c>true</c> [has irregular period].</param>
        /// <returns></returns>
        static public List <CalculationPeriod> GetBackwardRegularPeriods(DateTime startDate, DateTime endDate, Period periodInterval, RollConventionEnum rollConvention, out Boolean hasIrregularPeriod)
        {
            DateTime periodEndDate = startDate;

            hasIrregularPeriod = false;

            DateTime periodStartDate = AddPeriod(periodEndDate, periodInterval, -1);
            var      regularPeriods  = new List <CalculationPeriod>();

            while (true)
            {
                DateTime unadjustedStartDate = periodStartDate;
                DateTime unadjustedEndDate   = periodEndDate;
                if (rollConvention != RollConventionEnum.NONE)
                {
                    unadjustedStartDate = RollConventionEnumHelper.AdjustDate(rollConvention, periodStartDate);
                    unadjustedEndDate   = RollConventionEnumHelper.AdjustDate(rollConvention, periodEndDate);
                }

                CalculationPeriod calculationPeriod = CreateUnadjustedCalculationPeriod(unadjustedStartDate, unadjustedEndDate);

                if (calculationPeriod.unadjustedStartDate > endDate)
                {
                    regularPeriods.Insert(0, calculationPeriod);
                    periodEndDate   = periodStartDate;
                    periodStartDate = AddPeriod(periodEndDate, periodInterval, -1);
                }
                //last period - is not a stub
                else if (calculationPeriod.unadjustedStartDate == endDate)
                {
                    regularPeriods.Insert(0, calculationPeriod);
                    break;
                }
                else
                {
                    hasIrregularPeriod = true;
                    break;
                }
            }
            return(regularPeriods);
        }
示例#26
0
        /// <summary>
        /// Gets the unadjusted dates from effective date.
        /// </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="firstRegularPeriodStartDate">The first regular period start date.</param>
        /// <param name="lastRegularPeriodEndDate">The last regular period end date.</param>
        /// <returns></returns>
        public static DateTime[] GetUnadjustedDatesFromEffectiveDate(DateTime effectiveDate, DateTime terminationDate, Period periodInterval, RollConventionEnum rollConvention, out DateTime firstRegularPeriodStartDate, out DateTime lastRegularPeriodEndDate)
        {
            lastRegularPeriodEndDate = terminationDate;
            DateTime firstRollDate = effectiveDate;
            var      periodDates   = new List <DateTime> {
                firstRollDate
            };
            DateTime nextRollDate       = periodInterval.Add(firstRollDate);
            DateTime rollConventionDate = ApplyRollConventionToDate(rollConvention, nextRollDate);

            firstRegularPeriodStartDate = DateTime.Compare(nextRollDate, rollConventionDate) == 0 ? firstRollDate : rollConventionDate;
            periodDates.Add(rollConventionDate);
            Boolean reachedEnd = false;

            while (!reachedEnd)
            {
                rollConventionDate = periodInterval.Add(rollConventionDate);
                rollConventionDate = ApplyRollConventionToDate(rollConvention, rollConventionDate);
                if (rollConventionDate <= terminationDate)
                {
                    if (rollConventionDate.Month == terminationDate.Month && rollConventionDate.Year == terminationDate.Year)
                    {
                        periodDates.Add(terminationDate);
                        reachedEnd = true;
                        lastRegularPeriodEndDate = rollConventionDate.Day == terminationDate.Day ? periodDates[periodDates.Count - 1] : periodDates[periodDates.Count - 2];
                    }
                    else
                    {
                        periodDates.Add(rollConventionDate);
                    }
                }
                else
                {
                    reachedEnd = true;
                    lastRegularPeriodEndDate = periodDates[periodDates.Count - 1];
                    periodDates.Add(terminationDate);
                }
            }
            periodDates.Sort();
            return(periodDates.ToArray());
        }
示例#27
0
        /// <summary>
        /// Gets the unadjusted dates from maturity date. This assumes regular rolling from maturity date.
        /// </summary>
        /// <param name="effectiveDate">The effective date.</param>
        /// <param name="terminationDate">The termination date.</param>
        /// <param name="rollConvention">The roll convention.</param>
        /// <param name="periodInterval">The period interval.</param>
        /// <param name="lastCouponDate">The last coupon date.</param>
        /// <param name="nextCouponDate">The next coupon date.</param>
        /// <returns></returns>
        public static DateTime[] GetUnadjustedCouponDatesFromMaturityDate(DateTime effectiveDate, DateTime terminationDate, Period periodInterval, RollConventionEnum rollConvention, out DateTime lastCouponDate, out DateTime nextCouponDate)
        {
            var firstRollDate = terminationDate;
            var periodDates   = new List <DateTime> {
                firstRollDate
            };
            var nextRollDate       = periodInterval.Subtract(firstRollDate);
            var rollConventionDate = ApplyRollConventionToDate(rollConvention, nextRollDate);

            periodDates.Add(rollConventionDate);
            var reachedEnd = false;

            while (!reachedEnd)
            {
                rollConventionDate = periodInterval.Subtract(rollConventionDate);
                rollConventionDate = ApplyRollConventionToDate(rollConvention, rollConventionDate);
                periodDates.Add(rollConventionDate);

                if (rollConventionDate <= effectiveDate)
                {
                    reachedEnd = true;
                }
            }
            periodDates.Sort();
            lastCouponDate = periodDates[0];
            nextCouponDate = periodDates[1];
            return(periodDates.ToArray());
        }
 public PeriodicPayment(XmlNode xmlNode)
 : base(xmlNode)
 {
     XmlNodeList paymentFrequencyNodeList = xmlNode.SelectNodes("paymentFrequency");
     if (paymentFrequencyNodeList.Count > 1 )
     {
             throw new Exception();
     }
     
     foreach (XmlNode item in paymentFrequencyNodeList)
     {
         if (item.Attributes["href"] != null || item.Attributes["id"] == null) 
         {
             if (item.Attributes["id"] != null) 
             {
                 paymentFrequencyIDRef = item.Attributes["id"].Name;
                 Period ob = Period();
                 IDManager.SetID(paymentFrequencyIDRef, ob);
             }
             else if (item.Attributes.ToString() == "href")
             {
                 paymentFrequencyIDRef = item.Attributes["href"].Name;
             }
             else
             {
                 paymentFrequency = new Period(item);
             }
         }
     }
     
 
     XmlNodeList firstPeriodStartDateNodeList = xmlNode.SelectNodes("firstPeriodStartDate");
     if (firstPeriodStartDateNodeList.Count > 1 )
     {
             throw new Exception();
     }
     
     foreach (XmlNode item in firstPeriodStartDateNodeList)
     {
         if (item.Attributes["href"] != null || item.Attributes["id"] == null) 
         {
             if (item.Attributes["id"] != null) 
             {
                 firstPeriodStartDateIDRef = item.Attributes["id"].Name;
                 XsdTypeDate ob = XsdTypeDate();
                 IDManager.SetID(firstPeriodStartDateIDRef, ob);
             }
             else if (item.Attributes.ToString() == "href")
             {
                 firstPeriodStartDateIDRef = item.Attributes["href"].Name;
             }
             else
             {
                 firstPeriodStartDate = new XsdTypeDate(item);
             }
         }
     }
     
 
     XmlNodeList firstPaymentDateNodeList = xmlNode.SelectNodes("firstPaymentDate");
     if (firstPaymentDateNodeList.Count > 1 )
     {
             throw new Exception();
     }
     
     foreach (XmlNode item in firstPaymentDateNodeList)
     {
         if (item.Attributes["href"] != null || item.Attributes["id"] == null) 
         {
             if (item.Attributes["id"] != null) 
             {
                 firstPaymentDateIDRef = item.Attributes["id"].Name;
                 XsdTypeDate ob = XsdTypeDate();
                 IDManager.SetID(firstPaymentDateIDRef, ob);
             }
             else if (item.Attributes.ToString() == "href")
             {
                 firstPaymentDateIDRef = item.Attributes["href"].Name;
             }
             else
             {
                 firstPaymentDate = new XsdTypeDate(item);
             }
         }
     }
     
 
     XmlNodeList lastRegularPaymentDateNodeList = xmlNode.SelectNodes("lastRegularPaymentDate");
     if (lastRegularPaymentDateNodeList.Count > 1 )
     {
             throw new Exception();
     }
     
     foreach (XmlNode item in lastRegularPaymentDateNodeList)
     {
         if (item.Attributes["href"] != null || item.Attributes["id"] == null) 
         {
             if (item.Attributes["id"] != null) 
             {
                 lastRegularPaymentDateIDRef = item.Attributes["id"].Name;
                 XsdTypeDate ob = XsdTypeDate();
                 IDManager.SetID(lastRegularPaymentDateIDRef, ob);
             }
             else if (item.Attributes.ToString() == "href")
             {
                 lastRegularPaymentDateIDRef = item.Attributes["href"].Name;
             }
             else
             {
                 lastRegularPaymentDate = new XsdTypeDate(item);
             }
         }
     }
     
 
     XmlNodeList rollConventionNodeList = xmlNode.SelectNodes("rollConvention");
     if (rollConventionNodeList.Count > 1 )
     {
             throw new Exception();
     }
     
     foreach (XmlNode item in rollConventionNodeList)
     {
         if (item.Attributes["href"] != null || item.Attributes["id"] == null) 
         {
             if (item.Attributes["id"] != null) 
             {
                 rollConventionIDRef = item.Attributes["id"].Name;
                 RollConventionEnum ob = RollConventionEnum();
                 IDManager.SetID(rollConventionIDRef, ob);
             }
             else if (item.Attributes.ToString() == "href")
             {
                 rollConventionIDRef = item.Attributes["href"].Name;
             }
             else
             {
                 rollConvention = new RollConventionEnum(item);
             }
         }
     }
     
 
     XmlNodeList fixedAmountNodeList = xmlNode.SelectNodes("fixedAmount");
     if (fixedAmountNodeList.Count > 1 )
     {
             throw new Exception();
     }
     
     foreach (XmlNode item in fixedAmountNodeList)
     {
         if (item.Attributes["href"] != null || item.Attributes["id"] == null) 
         {
             if (item.Attributes["id"] != null) 
             {
                 fixedAmountIDRef = item.Attributes["id"].Name;
                 Money ob = Money();
                 IDManager.SetID(fixedAmountIDRef, ob);
             }
             else if (item.Attributes.ToString() == "href")
             {
                 fixedAmountIDRef = item.Attributes["href"].Name;
             }
             else
             {
                 fixedAmount = new Money(item);
             }
         }
     }
     
 
     XmlNodeList fixedAmountCalculationNodeList = xmlNode.SelectNodes("fixedAmountCalculation");
     if (fixedAmountCalculationNodeList.Count > 1 )
     {
             throw new Exception();
     }
     
     foreach (XmlNode item in fixedAmountCalculationNodeList)
     {
         if (item.Attributes["href"] != null || item.Attributes["id"] == null) 
         {
             if (item.Attributes["id"] != null) 
             {
                 fixedAmountCalculationIDRef = item.Attributes["id"].Name;
                 FixedAmountCalculation ob = FixedAmountCalculation();
                 IDManager.SetID(fixedAmountCalculationIDRef, ob);
             }
             else if (item.Attributes.ToString() == "href")
             {
                 fixedAmountCalculationIDRef = item.Attributes["href"].Name;
             }
             else
             {
                 fixedAmountCalculation = new FixedAmountCalculation(item);
             }
         }
     }
     
 
     XmlNodeList adjustedPaymentDatesNodeList = xmlNode.SelectNodes("adjustedPaymentDates");
     
     foreach (XmlNode item in adjustedPaymentDatesNodeList)
     {
         if (item.Attributes["href"] != null || item.Attributes["id"] == null) 
         {
             if (item.Attributes["id"] != null) 
             {
                 adjustedPaymentDatesIDRef = item.Attributes["id"].Name;
                 List<AdjustedPaymentDates> ob = new List<AdjustedPaymentDates>();
                 ob.Add(new AdjustedPaymentDates(item));
                 IDManager.SetID(adjustedPaymentDatesIDRef, ob);
             }
             else if (item.Attributes.ToString() == "href")
             {
                 adjustedPaymentDatesIDRef = item.Attributes["href"].Name;
             }
             else
             {
             adjustedPaymentDates.Add(new AdjustedPaymentDates(item));
             }
         }
     }
     
 
 }