예제 #1
0
 /// <summary>Initializes a new instance of the <see cref="BackwardDateScheduleRule"/> class.
 /// </summary>
 /// <param name="referenceDate">A reference date used to calculate the start date and end date of the date schedule with respect to <paramref name="startAndEndDateDescription"/>.</param>
 /// <param name="startAndEndDateDescription">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>
 /// <remarks>The optional <paramref name="firstRegularDate"/> and <paramref name="lastRegularDate"/> are used to generated a short/long first/last stub period.</remarks>
 public BackwardDateScheduleRule(DateTime referenceDate, 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;
     m_ReferenceDate       = referenceDate;
 }
예제 #2
0
파일: IMM.cs 프로젝트: xiaodelea/dodoni.net
 /// <summary>Creates a new <see cref="ITimeframeDescription"/> object, where the start date of the period is the next IMM date with respect to the reference date of the time period calculation.</summary>
 /// <param name="tenor">The tenor that represents the time span.</param>
 /// <param name="startDateAdjustment">A business day convention used to compute the start date of the period, i.e. the IMM date.</param>
 /// <param name="endDateAdjustment">A business day convention used to compute the end date of the period.</param>
 /// <returns>The specified <see cref="ITimeframeDescription"/> object.</returns>
 public static ITimeframeDescription Create(TenorTimeSpan tenor, IBusinessDayConvention startDateAdjustment, IBusinessDayConvention endDateAdjustment)
 {
     return(new NextPeriod(tenor, startDateAdjustment, endDateAdjustment));
 }
예제 #3
0
        /// <summary>Initializes a new instance of the <see cref="BackwardDateScheduleRule"/> class.
        /// </summary>
        /// <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>
        private BackwardDateScheduleRule(IDateScheduleFrequency frequency, IBusinessDayConvention businessDayConvention, IBusinessDayConvention seedBusinessDayConvention = null, DateTime?firstRegularDate = null, DateTime?lastRegularDate = null)
        {
            if (frequency == null)
            {
                throw new ArgumentNullException("frequency");
            }
            m_Frequency = frequency;
            if (businessDayConvention == null)
            {
                throw new ArgumentNullException("businessDayConvention");
            }
            m_BusinessDayConvention = businessDayConvention;

            m_ReferenceDate = DateTime.MinValue;

            // the optional parameters
            m_SeedBusinessDayConvention = seedBusinessDayConvention;
            m_FirstRegularDate          = firstRegularDate;
            m_LastRegularDate           = lastRegularDate;
        }
예제 #4
0
            /// <summary>Initializes a new instance of the <see cref="NextPeriod"/> class.
            /// </summary>
            /// <param name="tenor">The tenor that represents the time span.</param>
            /// <param name="startDateAdjustment">A business day convention used to compute the start date of the period, i.e. the IMM date.</param>
            /// <param name="endDateAdjustment">A business day convention used to compute the end date of the period.</param>
            public NextPeriod(TenorTimeSpan tenor, IBusinessDayConvention startDateAdjustment, IBusinessDayConvention endDateAdjustment)
            {
                Tenor = tenor;

                if (startDateAdjustment == null)
                {
                    throw new ArgumentNullException("startDateAdjustment");
                }
                StartDateAdjustment = startDateAdjustment;

                if (endDateAdjustment == null)
                {
                    throw new ArgumentNullException("endDateAdjustment");
                }
                EndDateAdjustment = endDateAdjustment;
            }
예제 #5
0
파일: IMM.cs 프로젝트: xiaodelea/dodoni.net
 /// <summary>Creates a new <see cref="ITimeframeDescription"/> object, where the start date of the period is a IMM date.</summary>
 /// <param name="month">The month of the period start date in its <see cref="IMM.Month"/> representation.</param>
 /// <param name="periodStartYearOffset">The number of years to add to the reference date in <c>GetStartAndEndDate(.)</c> to take into account for the calculation of the specific IMM date.</param>
 /// <param name="tenor">The tenor that represents the time span.</param>
 /// <param name="startDateAdjustment">A business day convention used to compute the start date of the period, i.e. the IMM date.</param>
 /// <param name="endDateAdjustment">A business day convention used to compute the end date of the period.</param>
 /// <returns>The specified <see cref="ITimeframeDescription"/> object.</returns>
 public static ITimeframeDescription Create(Month month, int periodStartYearOffset, TenorTimeSpan tenor, IBusinessDayConvention startDateAdjustment, IBusinessDayConvention endDateAdjustment)
 {
     return(new SpecificPeriod(month, periodStartYearOffset, tenor, startDateAdjustment, endDateAdjustment));
 }
예제 #6
0
 /// <summary>Creates a new <see cref="ITimeframeDescription"/> object.
 /// </summary>
 /// <param name="startDateTenor">The tenor use to calculate the start date.</param>
 /// <param name="tenor">The tenor that represents the time span.</param>
 /// <param name="spotDateAdjustment">A business day convention used to compute the spot date (= reference date + a number of business days to settle [if <paramref name="startDateTenor"/> is regular or one business day in the case of tomorrow-next]); if <c>null</c> no adjustment will be applied.</param>
 /// <param name="startDateAdjustment">A business day convention used to compute the start date of the timeframe; if <c>null</c> no adjustment will be applied.</param>
 /// <param name="endDateAdjustment">A business day convention used to compute the end date of the timeframe; if <c>null</c> no adjustment will be applied.</param>
 /// <param name="businessDaysToSettle">The number of business days used to calculate the spot date; this parameter will be taken into account if and only if <paramref name="startDateTenor"/> is a regular tenor (i.e. neigther overnight nor tomorrow-next).</param>
 /// <returns>A <see cref="ITimeframeDescription"/> object where the implementation works in the following way:
 /// <para>The implementation works in the following way:
 ///  <list type="number">
 ///   <item><description>Apply the SpotDateAdjustment to the reference date; call it spot date.</description></item>
 ///   <item><description>For regular tenor with a number of business days to settle [in short: BD-ToSettle] != 0 or tomorrow-next, point the spot date to the
 ///   next (or previous if BD-ToSettle is lesss than 0) business day and add BD-ToSettle business days. This is the final spot date.</description></item>
 ///   <item><description>Apply the start tenor to the spot date and apply the StartDateAdjustment. This is the start date of the period.</description></item>
 ///   <item><description>Add the tenor to the start date and apply the EndDateAdjustment which gives us the end date.</description></item>
 /// </list></para></returns>
 /// <exception cref="ArgumentException">Thrown, if <paramref name="startDateTenor"/> or <paramref name="tenor"/> represents a negative time span.</exception>
 public static ITimeframeDescription Create(TenorTimeSpan startDateTenor, TenorTimeSpan tenor, IBusinessDayConvention spotDateAdjustment, IBusinessDayConvention startDateAdjustment, IBusinessDayConvention endDateAdjustment, int businessDaysToSettle = 0)
 {
     return(new ForwardStartingTimeframeDescription(startDateTenor, tenor, (spotDateAdjustment != null) ? spotDateAdjustment : sm_NoAdjustment, (startDateAdjustment != null) ? startDateAdjustment : sm_NoAdjustment, (endDateAdjustment != null) ? endDateAdjustment : sm_NoAdjustment, businessDaysToSettle));
 }
예제 #7
0
 /// <summary>Creates a new <see cref="ITimeframeDescription"/> object.
 /// </summary>
 /// <param name="startDateTenor">The tenor use to calculate the start date.</param>
 /// <param name="tenor">The tenor that represents the time span.</param>
 /// <param name="businessDayConvention">The business day convention used to compute the spot date, start date as well as the end date of the timeframe.</param>
 /// <param name="businessDaysToSettle">The number of business days used to calculate the spot date; this parameter will be taken into account if and only if <paramref name="startDateTenor"/> is a regular tenor (i.e. neigther overnight nor tomorrow-next).</param>
 /// <returns>A <see cref="ITimeframeDescription"/> object where the implementation works in the following way:
 /// <para>The implementation works in the following way:
 ///  <list type="number">
 ///   <item><description>Apply the SpotDateAdjustment to the reference date; call it spot date.</description></item>
 ///   <item><description>For regular tenor with a number of business days to settle [in short: BD-ToSettle] != 0 or tomorrow-next, point the spot date to the
 ///   next (or previous if BD-ToSettle is lesss than 0) business day and add BD-ToSettle business days. This is the final spot date.</description></item>
 ///   <item><description>Apply the start tenor to the spot date and apply the StartDateAdjustment. This is the start date of the period.</description></item>
 ///   <item><description>Add the tenor to the start date and apply the EndDateAdjustment which gives us the end date.</description></item>
 /// </list></para></returns>
 /// <exception cref="ArgumentException">Thrown, if <paramref name="startDateTenor"/> or <paramref name="tenor"/> represents a negative time span.</exception>
 /// <exception cref="ArgumentNullException">Thrown, if <paramref name="businessDayConvention"/> is <c>null</c>.</exception>
 public static ITimeframeDescription Create(TenorTimeSpan startDateTenor, TenorTimeSpan tenor, IBusinessDayConvention businessDayConvention, int businessDaysToSettle = 0)
 {
     if (businessDayConvention == null)
     {
         throw new ArgumentNullException("businessDayConvention");
     }
     return(new ForwardStartingTimeframeDescription(startDateTenor, tenor, businessDayConvention, businessDayConvention, businessDayConvention, businessDaysToSettle));
 }
예제 #8
0
            /// <summary>Initializes a new instance of the <see cref="SpecificPeriod"/> class.
            /// </summary>
            /// <param name="month">The month of the period start date in its <see cref="IMM.Month"/> representation.</param>
            /// <param name="periodStartYearOffset">The number of years to add to the reference date in <c>GetStartAndEndDate(.)</c> to take into account for the calculation of the specific IMM date.</param>
            /// <param name="tenor">The tenor that represents the time span.</param>
            /// <param name="startDateAdjustment">A business day convention used to compute the start date of the period, i.e. the IMM date.</param>
            /// <param name="endDateAdjustment">A business day convention used to compute the end date of the period.</param>
            public SpecificPeriod(Month month, int periodStartYearOffset, TenorTimeSpan tenor, IBusinessDayConvention startDateAdjustment, IBusinessDayConvention endDateAdjustment)
            {
                Tenor                 = tenor;
                PeriodStartMonth      = month;
                PeriodStartYearOffset = periodStartYearOffset;

                if (startDateAdjustment == null)
                {
                    throw new ArgumentNullException("startDateAdjustment");
                }
                StartDateAdjustment = startDateAdjustment;

                if (endDateAdjustment == null)
                {
                    throw new ArgumentNullException("endDateAdjustment");
                }
                EndDateAdjustment = endDateAdjustment;
            }
예제 #9
0
 /// <summary>Creates a new <see cref="ITimeframeDescription"/> object.
 /// </summary>
 /// <param name="endDate">The end date of the timeframe.</param>
 /// <param name="spotDateAdjustment">A business day convention used to compute the spot date (= reference date + a number of business days to settle; if <c>null</c> no adjustment will be applied.</param>
 /// <param name="startDateAdjustment">A business day convention used to compute the start date of the timeframe; if <c>null</c> no adjustment will be applied.</param>
 /// <param name="endDateAdjustment">A business day convention used to compute the end date of the timeframe; if <c>null</c> no adjustment will be applied.</param>
 /// <param name="businessDaysToSettle">The number of business days used to calculate the spot date.</param>
 /// <returns>A <see cref="ITimeframeDescription"/> object where the implementation works in the following way:
 ///  <list type="number">
 ///   <item><description>Apply the SpotDateAdjustment to the reference date; call it spot date.</description></item>
 ///   <item><description>Point the spot date to the next business day if the number of business days to settle is strictly greater than 0 or to the previous business day if
 ///   the number of business days to settle is strictly less than 0. Add the number of business days to settle which defines the final spot date.</description></item>
 ///   <item><description>Apply the StartDateAdjustment to the spot date. This is the start date of the period.</description></item>
 ///   <item><description>Apply the EndDateAdjustment to the specified end date; this is the end date of the timeframe.</description></item>
 /// </list></returns>
 public static ITimeframeDescription Create(DateTime endDate, IBusinessDayConvention spotDateAdjustment = null, IBusinessDayConvention startDateAdjustment = null, IBusinessDayConvention endDateAdjustment = null, int businessDaysToSettle = 0)
 {
     return(new DateTimeTimeframeDescription(endDate, (spotDateAdjustment != null) ? spotDateAdjustment : sm_NoAdjustment, (startDateAdjustment != null) ? startDateAdjustment : sm_NoAdjustment, (endDateAdjustment != null) ? endDateAdjustment : sm_NoAdjustment, businessDaysToSettle));
 }
 /// <summary>Initializes a new instance of the <see cref="DateTimeTimeframeDescription"/> class.
 /// </summary>
 /// <param name="endDate">The end date of the timeframe.</param>
 /// <param name="spotDateAdjustment">A business day convention used to compute the spot date (= reference date + a number of business days to settle).</param>
 /// <param name="startDateAdjustment">A business day convention used to compute the start date of the period.</param>
 /// <param name="endDateAdjustment">A business day convention used to compute the end date of the period.</param>
 /// <param name="businessDaysToSettle">The number of business days used to calculate the spot date.</param>
 /// <exception cref="ArgumentNullException">Thrown, if one of the <see cref="IBusinessDayConvention"/> arguments is <c>null</c>.</exception>
 public DateTimeTimeframeDescription(DateTime endDate, IBusinessDayConvention spotDateAdjustment, IBusinessDayConvention startDateAdjustment, IBusinessDayConvention endDateAdjustment, int businessDaysToSettle = 0)
 {
     EndDate = endDate;
     if (spotDateAdjustment == null)
     {
         throw new ArgumentNullException("spotDateAdjustment");
     }
     SpotDateAdjustment = spotDateAdjustment;
     if (startDateAdjustment == null)
     {
         throw new ArgumentNullException("startDateAdjustment");
     }
     StartDateAdjustment = startDateAdjustment;
     if (endDateAdjustment == null)
     {
         throw new ArgumentNullException("endDateAdjustment");
     }
     EndDateAdjustment    = endDateAdjustment;
     BusinessDaysToSettle = businessDaysToSettle;
 }
 /// <summary>Initializes a new instance of the <see cref="ForwardStartingTimeframeDescription"/> class.
 /// </summary>
 /// <param name="startDateTenor">The tenor use to calculate the start date.</param>
 /// <param name="tenor">The tenor that represents the time span.</param>
 /// <param name="spotDateAdjustment">A business day convention used to compute the spot date, i.e. reference date + a number of business days to settle (if <paramref name="startDateTenor"/> is regular).</param>
 /// <param name="startDateAdjustment">A business day convention used to compute the start date of the period.</param>
 /// <param name="endDateAdjustment">A business day convention used to compute the end date of the period.</param>
 /// <param name="businessDaysToSettle">The number of business days used to calculate the spot date; this parameter will be taken into if and only if <paramref name="startDateTenor"/> is a regular tenor (i.e. neigther overnight nor tomorrow-next).</param>
 /// <exception cref="ArgumentException">Thrown, if <paramref name="startDateTenor"/> or <paramref name="tenor"/> represents a negative time span or <paramref name="tenor"/> does not represents a regular tenor (<see cref="TenorType.RegularTenor"/>).</exception>
 /// <exception cref="ArgumentNullException">Thrown, if one of the <see cref="IBusinessDayConvention"/> arguments is <c>null</c>.</exception>
 public ForwardStartingTimeframeDescription(TenorTimeSpan startDateTenor, TenorTimeSpan tenor, IBusinessDayConvention spotDateAdjustment, IBusinessDayConvention startDateAdjustment, IBusinessDayConvention endDateAdjustment, int businessDaysToSettle = 0)
 {
     if (startDateTenor.IsPositive == false)
     {
         throw new ArgumentException(String.Format(ExceptionMessages.ArgumentIsInvalid, startDateTenor.ToString()), "startDateTenor");
     }
     StartDateTenor = startDateTenor;
     if ((tenor.IsPositive == false) || (tenor.TenorType != TenorType.RegularTenor))  // ON, TN are not allowed
     {
         throw new ArgumentException(String.Format(ExceptionMessages.ArgumentIsInvalid, tenor.ToString()), "tenor");
     }
     Tenor = tenor;
     if (spotDateAdjustment == null)
     {
         throw new ArgumentNullException("spotDateAdjustment");
     }
     SpotDateAdjustment = spotDateAdjustment;
     if (startDateAdjustment == null)
     {
         throw new ArgumentNullException("startDateAdjustment");
     }
     StartDateAdjustment = startDateAdjustment;
     if (endDateAdjustment == null)
     {
         throw new ArgumentNullException("endDateAdjustment");
     }
     EndDateAdjustment    = endDateAdjustment;
     BusinessDaysToSettle = businessDaysToSettle;
 }
 /// <summary>Initializes a new instance of the <see cref="TenorTimeframeDescription"/> class.
 /// </summary>
 /// <param name="tenor">The tenor that represents the time span.</param>
 /// <param name="spotDateAdjustment">A business day convention used to compute the spot date, i.e. reference date + a number of business days to settle (if <paramref name="tenor"/> is regular).</param>
 /// <param name="startDateAdjustment">A business day convention used to compute the start date of the period.</param>
 /// <param name="endDateAdjustment">A business day convention used to compute the end date of the period.</param>
 /// <param name="businessDaysToSettle">The number of business days used to calculate the spot date; this parameter will be taken into if and only if <paramref name="tenor"/> is a regular tenor (i.e. neigther overnight nor tomorrow-next).</param>
 /// <exception cref="ArgumentException">Thrown, if <paramref name="tenor"/> represents a negative time span.</exception>
 /// <exception cref="ArgumentNullException">Thrown, if one of the <see cref="IBusinessDayConvention"/> arguments is <c>null</c>.</exception>
 public TenorTimeframeDescription(TenorTimeSpan tenor, IBusinessDayConvention spotDateAdjustment, IBusinessDayConvention startDateAdjustment, IBusinessDayConvention endDateAdjustment, int businessDaysToSettle = 0)
 {
     if (tenor.IsPositive == false)
     {
         throw new ArgumentException(String.Format(ExceptionMessages.ArgumentIsInvalid, tenor.ToString()), "tenor");
     }
     Tenor = tenor;
     if (spotDateAdjustment == null)
     {
         throw new ArgumentNullException("spotDateAdjustment");
     }
     SpotDateAdjustment = spotDateAdjustment;
     if (startDateAdjustment == null)
     {
         throw new ArgumentNullException("startDateAdjustment");
     }
     StartDateAdjustment = startDateAdjustment;
     if (endDateAdjustment == null)
     {
         throw new ArgumentNullException("endDateAdjustment");
     }
     EndDateAdjustment    = endDateAdjustment;
     BusinessDaysToSettle = businessDaysToSettle;
 }
예제 #13
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 ForwardDateScheduleRule(startAndEndDateDescription, frequency, businessDayConvention, seedBusinessDayConvention, firstRegularDate, lastRegularDate);
 }
예제 #14
0
 /// <summary>Creates a <see cref="IDateScheduleRuleDescription"/> wrapper for <see cref="ForwardDateScheduleRule"/> 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="firstRegularDate"/> 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="ForwardDateScheduleRule"/> 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));
 }