Exemple #1
0
 /// <summary>Initializes a new instance of the <see cref="BackwardDateScheduleRule"/> class.
 /// </summary>
 /// <param name="startAndEndDateDescription">A description of the start and end date to take into account in its <see cref="ITimeframeDescription"/> representation.</param>
 /// <param name="frequency">The frequency.</param>
 /// <param name="businessDayConvention">The business day convention.</param>
 /// <param name="seedBusinessDayConvention">The optional seed business day convention, represents the adjustment of the
 /// 'seed date' used in the main date generation loop, i.e. generates
 /// <para>
 ///     'adjusted seed date' + j * tenor, j=1,2,...
 /// </para>
 /// and adjust these dates with respect to <paramref name="businessDayConvention"/> (optional; will be ignored if <paramref name="firstRegularDate"/> is a date).
 /// </param>
 /// <param name="firstRegularDate">The first regular date (optional).</param>
 /// <param name="lastRegularDate">The last regular date (optional).</param>
 /// <remarks>The optional <paramref name="firstRegularDate"/> and <paramref name="lastRegularDate"/> are used to generated a short/long first/last stub period.
 /// <para>A object created by this constructor is not ready to use, because the reference date with respect to <paramref name="startAndEndDateDescription"/> has to be specified;
 /// call <see cref="GetAdaptedDateScheduleRule(DateTime)"/> to create a valid object.</para></remarks>
 private BackwardDateScheduleRule(ITimeframeDescription startAndEndDateDescription, IDateScheduleFrequency frequency, IBusinessDayConvention businessDayConvention, IBusinessDayConvention seedBusinessDayConvention = null, DateTime?firstRegularDate = null, DateTime?lastRegularDate = null)
     : this(frequency, businessDayConvention, seedBusinessDayConvention, firstRegularDate, lastRegularDate)
 {
     if (startAndEndDateDescription == null)
     {
         throw new ArgumentNullException("startAndEndDateDescription");
     }
     m_TimeSpanDescription = startAndEndDateDescription;
 }
Exemple #2
0
        /// <summary>Creates a date schedule that contains the start and end dates of the interest periods of each caplets, i.e. T_0, T_1, T_2, ..., where [T_k; T_{k+1}] is the
        /// interest period of caplet k, k=0,...,n-1; The first caplet is already expired but it is part of the date schedule.
        /// </summary>
        /// <param name="referenceDate">The reference date, i.e. the trading date.</param>
        /// <param name="startDateAndEndDateDescription">A description of the start date of the first caplet as well as the end date of the last caplet, i.e. the start date and the maturity of the cap.</param>
        /// <param name="marketConventions">The market conventions.</param>
        /// <param name="holidayCalendar">The holiday calendar.</param>
        /// <param name="underlyingLiborTenor">A mapping of the null-based index of the start date of each caplet interest period to the tenor of the underlying Libor rate (output).</param>
        /// <param name="logger">An optional logger.</param>
        /// <returns>
        /// The date schedule of the interest periods, i.e. the start and end dates of each caplet; thus T_0, T_1, T_2, ..., where [T_k; T_{k+1}] is the
        /// interest period of caplet k, k=0,...,n-1; The first caplet is already expired but it is part of the date schedule.
        /// </returns>
        public ReadOnlyDateSchedule CreateInterestPeriodDateSchedule(DateTime referenceDate, ITimeframeDescription startDateAndEndDateDescription, ReadOnlyMoneyMarketConventions marketConventions, IHolidayCalendar holidayCalendar, out Func <int, TenorTimeSpan> underlyingLiborTenor, ILogger logger = null)
        {
            if (marketConventions == null)
            {
                throw new ArgumentNullException("marketConventions");
            }
            if (holidayCalendar == null)
            {
                throw new ArgumentNullException("holidayCalendar");
            }
            IBusinessDayConvention businessDayConvention = marketConventions.BusinessDayConvention;

            DateTime capStartDate, capEndDate;

            startDateAndEndDateDescription.GetStartAndEndDate(referenceDate, holidayCalendar, out capStartDate, out capEndDate);

            DateTime lastDate3M = businessDayConvention.GetAdjustedDate(capStartDate.AddTenorTimeSpan(sm_2YTenor), holidayCalendar); // it is the end date of the latest caplet with tenor 3M

            DateSchedule dateSchedule = new DateSchedule(holidayCalendar, logger: logger);

            if (capEndDate <= lastDate3M)
            {
                dateSchedule.Add(new ForwardDateScheduleRule(referenceDate, startDateAndEndDateDescription, sm_3MLiborRateTenor, businessDayConvention));
                underlyingLiborTenor = (i => sm_3MLiborRateTenor.GetFrequencyTenor());
            }
            else
            {
                ITimeframeDescription firstPeriod3M = TimeframeDescription.Create(lastDate3M);  // applied to reference date='capStartDate' shows [capStartDate; lastDate3M]
                dateSchedule.Add(new ForwardDateScheduleRule(capStartDate, firstPeriod3M, sm_3MLiborRateTenor, businessDayConvention));
                int indexOfLast3MPeriodEndDate = dateSchedule.Count - 1;

                ITimeframeDescription secondPeriod6M = TimeframeDescription.Create(capEndDate, endDateAdjustment: businessDayConvention); // applied to reference date ='lastDate3M' shows [lastDate3M; capEndDate]
                dateSchedule.Add(new ForwardDateScheduleRule(lastDate3M, secondPeriod6M, sm_6MLiborRateTenor, businessDayConvention));
                underlyingLiborTenor = (i => (i < indexOfLast3MPeriodEndDate) ? sm_3MLiborRateTenor.GetFrequencyTenor() : sm_3MLiborRateTenor.GetFrequencyTenor());
            }
            return(dateSchedule.AsReadOnly());
        }
        /// <summary>Creates a date schedule that contains the start and end dates of the interest periods of each caplets, i.e. T_0, T_1, T_2, ..., where [T_k; T_{k+1}] is the
        /// interest period of caplet k, k=0,...,n-1; The first caplet is already expired but it is part of the date schedule.
        /// </summary>
        /// <param name="referenceDate">The reference date, i.e. the trading date.</param>
        /// <param name="startDateAndEndDateDescription">A description of the start date of the first caplet as well as the end date of the last caplet, i.e. the start date and the maturity of the cap.</param>
        /// <param name="marketConventions">The market conventions.</param>
        /// <param name="holidayCalendar">The holiday calendar.</param>
        /// <param name="underlyingLiborTenor">A mapping of the null-based index of the start date of each caplet interest period to the tenor of the underlying Libor rate (output).</param>
        /// <param name="logger">An optional logger.</param>
        /// <returns>The date schedule of the interest periods, i.e. the start and end dates of each caplet; thus T_0, T_1, T_2, ..., where [T_k; T_{k+1}] is the
        /// interest period of caplet k, k=0,...,n-1; The first caplet is already expired but it is part of the date schedule.
        /// </returns>
        public ReadOnlyDateSchedule CreateInterestPeriodDateSchedule(DateTime referenceDate, ITimeframeDescription startDateAndEndDateDescription, ReadOnlyMoneyMarketConventions marketConventions, IHolidayCalendar holidayCalendar, out Func <int, TenorTimeSpan> underlyingLiborTenor, ILogger logger = null)
        {
            if (marketConventions == null)
            {
                throw new ArgumentNullException("marketConventions");
            }
            if (holidayCalendar == null)
            {
                throw new ArgumentNullException("holidayCalendar");
            }
            DateSchedule dateSchedule = new DateSchedule(holidayCalendar, logger: logger);

            dateSchedule.Add(new ForwardDateScheduleRule(referenceDate, startDateAndEndDateDescription, m_LiborRateTenor, marketConventions.BusinessDayConvention));

            underlyingLiborTenor = (i => m_LiborRateTenor.GetFrequencyTenor());
            return(dateSchedule.AsReadOnly());
        }
Exemple #4
0
 /// <summary>Initializes a new instance of the <see cref="DateScheduleRuleDescription "/> class.
 /// </summary>
 /// <param name="startAndEndDateDescription">The description of the start and of the end date of the date schedule.</param>
 /// <param name="frequency">The frequency.</param>
 /// <param name="businessDayConvention">The business day convention.</param>
 /// <param name="seedBusinessDayConvention">The optional seed business day convention, represents the adjustment of the
 /// 'seed date' used in the main date generation loop, i.e. generates
 /// <para>
 ///     'adjusted seed date' - j * tenor, j=1,2,...
 /// </para>
 /// and adjust these dates with respect to <paramref name="businessDayConvention"/> (optional; will be ignored if <paramref name="firstRegularDate"/> is a date).
 /// </param>
 /// <param name="firstRegularDate">The first regular date (optional).</param>
 /// <param name="lastRegularDate">The last regular date (optional).</param>
 /// <remarks>The optional <paramref name="firstRegularDate"/> and <paramref name="lastRegularDate"/> are used to generated a short/long first/last stub period.</remarks>
 public DateScheduleRuleDescription(ITimeframeDescription startAndEndDateDescription, IDateScheduleFrequency frequency, IBusinessDayConvention businessDayConvention, IBusinessDayConvention seedBusinessDayConvention, DateTime?firstRegularDate = null, DateTime?lastRegularDate = null)
 {
     m_DateScheduleRule = new BackwardDateScheduleRule(startAndEndDateDescription, frequency, businessDayConvention, seedBusinessDayConvention, firstRegularDate, lastRegularDate);
 }
Exemple #5
0
 /// <summary>Creates a <see cref="IDateScheduleRuleDescription"/> wrapper for <see cref="BackwardDateScheduleRule"/> objects.
 /// </summary>
 /// <param name="startAndEndDatePeriodDescription">A description of the start date and the end date of the date schedule.</param>
 /// <param name="businessDayConvention">The business day convention.</param>
 /// <param name="frequency">The frequency.</param>
 /// <param name="seedBusinessDayConvention">The optional seed business day convention, represents the adjustment of the
 /// 'seed date' used in the main date generation loop, i.e. generates
 /// <para>
 ///     'adjusted seed date' - j * tenor, j=1,2,...
 /// </para>
 /// and adjust these dates with respect to <paramref name="businessDayConvention"/> (optional; will be ignored if <paramref name="lastRegularDate"/> is a date; if <c>null</c> <paramref name="businessDayConvention"/> will be used).
 /// </param>
 /// <param name="firstRegularDate">The first regular date (optional).</param>
 /// <param name="lastRegularDate">The last regular date (optional).</param>
 /// <returns>A <see cref="IDateScheduleRuleDescription"/> object that encapsulate a <see cref="BackwardDateScheduleRule"/> object.</returns>
 /// <remarks>The optional <paramref name="firstRegularDate"/> and <paramref name="lastRegularDate"/> are used to generated a short/long first/last stub period.</remarks>
 public static IDateScheduleRuleDescription CreateDescriptor(ITimeframeDescription startAndEndDatePeriodDescription, IDateScheduleFrequency frequency, IBusinessDayConvention businessDayConvention, IBusinessDayConvention seedBusinessDayConvention = null, DateTime?firstRegularDate = null, DateTime?lastRegularDate = null)
 {
     return(new DateScheduleRuleDescription(startAndEndDatePeriodDescription, frequency, businessDayConvention, seedBusinessDayConvention, firstRegularDate, lastRegularDate));
 }