Ejemplo n.º 1
0
        public Schedule value()
        {
            // check for mandatory arguments
            Utils.QL_REQUIRE(effectiveDate_ != null, () => "effective date not provided");
            Utils.QL_REQUIRE(terminationDate_ != null, () => "termination date not provided");
            Utils.QL_REQUIRE((object)tenor_ != null, () => "tenor/frequency not provided");

            // if no calendar was set...
            if (calendar_ == null)
            {
                // ...we use a null one.
                calendar_ = new NullCalendar();
            }

            // set dynamic defaults:
            BusinessDayConvention convention;

            // if a convention was set, we use it.
            if (convention_ != null)
            {
                convention = convention_.Value;
            }
            else
            {
                if (!calendar_.empty())
                {
                    // ...if we set a calendar, we probably want it to be used;
                    convention = BusinessDayConvention.Following;
                }
                else
                {
                    // if not, we don't care.
                    convention = BusinessDayConvention.Unadjusted;
                }
            }

            BusinessDayConvention terminationDateConvention;

            // if set explicitly, we use it;
            if (terminationDateConvention_ != null)
            {
                terminationDateConvention = terminationDateConvention_.Value;
            }
            else
            {
                // Unadjusted as per ISDA specification
                terminationDateConvention = convention;
            }

            return(new Schedule(effectiveDate_, terminationDate_, tenor_, calendar_,
                                convention, terminationDateConvention,
                                rule_, endOfMonth_, firstDate_, nextToLastDate_));
        }