Exemplo n.º 1
0
        /// <summary>
        /// Validate settlement dates.
        /// If not sorted then add a warning to errors list and sort.
        /// </summary>
        public void Validate(ErrorList errors, double endDate)
        {
            foreach (ExerciseProperties exercise in this)
            {
                if (exercise.Settlement_Date < exercise.Exercise_Date)
                {
                    errors.Add(ErrorLevel.Error, string.Format("Settlement date must be on or after exercise date {0}", exercise.Exercise_Date));
                }

                if (endDate < exercise.Exercise_Date)
                {
                    errors.Add(ErrorLevel.Warning, string.Format("Exercise dates cannot be after the end date {0} of the underlying deals. Exercise date {1} will be ignored.", new TDate(endDate), exercise.Exercise_Date));
                }
            }

            if (!CalcUtils.IsListSorted <ExerciseProperties>(this))
            {
                errors.Add(ErrorLevel.Warning, "Exercise dates were not in ascending order of date and have been sorted");
                Sort();
            }
        }