/// <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;
 }
Ejemplo n.º 2
0
        /// <summary>Gets a date schedule frequency.
        /// </summary>
        /// <param name="frequency">The frequency in its <see cref="System.String"/> representation; perhaps a <see cref="TenorTimeSpan"/> in its <see cref="System.String"/> representation.</param>
        /// <param name="value">The date schedule frequency (output).</param>
        /// <param name="addIntoPool">If <paramref name="frequency"/> represents a individual frequency,
        /// the corresponding <see cref="IDateScheduleFrequency"/> will be added to the <see cref="DateScheduleFrequency"/> if set to <c>true</c>.</param>
        /// <returns>A value indicating whether <paramref name="value"/> contains valid data.</returns>
        /// <remarks>If <paramref name="frequency"/> does not represents an item of the pool, try to create to convert <paramref name="frequency"/> to a  <see cref="TenorTimeSpan"/> object first.</remarks>
        public static bool TryGetValue(string frequency, out IDateScheduleFrequency value, bool addIntoPool = false)
        {
            if ((frequency == null) || (frequency.Length == 0))
            {
                value = null;
                return(false);
            }
            if (sm_Pool.TryGetValue(frequency, out value) == true)
            {
                return(true);
            }

            TenorTimeSpan tenorFrequency;   // try to generate a individual frequency:

            if (TenorTimeSpan.TryParse(frequency, out tenorFrequency) == false)
            {
                value = null;
                return(false);
            }
            if (IndividualDateScheduleFrequency.TryCreate(tenorFrequency, out value) == true)
            {
                if (addIntoPool)
                {
                    sm_Pool.Add(value);
                }
                return(true);
            }
            value = null;
            return(false);
        }
        /// <summary>Initializes a new instance of the <see cref="PeriodicInterestCompounding"/> class.
        /// </summary>
        /// <param name="frequency">The frequency of the compounding.</param>
        protected internal PeriodicInterestCompounding(IDateScheduleFrequency frequency)
        {
            if (frequency == null)
            {
                throw new ArgumentNullException("frequency");
            }
            Frequency = frequency;

            TenorTimeSpan frequencyTenor = frequency.GetFrequencyTenor();

            if (TenorTimeSpan.IsNull(frequencyTenor) == true)
            {
                throw new ArgumentException("frequency");
            }

            if (frequencyTenor.Years != 0)
            {
                PaymentsPerYear = 1.0 / frequencyTenor.Years;
            }
            if (frequencyTenor.Months != 0)
            {
                PaymentsPerYear += 12.0 / frequencyTenor.Months;
            }
            if (frequencyTenor.Days != 0)
            {
                PaymentsPerYear += 365.0 / frequencyTenor.Days;
            }
        }
        /// <summary>Initializes a new instance of the <see cref="SimpleThenPeriodicCompounding" /> class.
        /// </summary>
        /// <param name="frequency">The frequency of the compounding to apply after time-to-maturity of one year.</param>
        internal SimpleThenPeriodicCompounding(IDateScheduleFrequency frequency)
        {
            if (frequency == null)
            {
                throw new ArgumentNullException("frequency");
            }
            Frequency = frequency;

            var frequencyTenor = frequency.GetFrequencyTenor();

            if (TenorTimeSpan.IsNull(frequencyTenor) == true)
            {
                throw new ArgumentException("frequency");
            }

            if (frequencyTenor.Years != 0)
            {
                PaymentsPerYear = 1.0 / frequencyTenor.Years;
            }
            if (frequencyTenor.Months != 0)
            {
                PaymentsPerYear += 12.0 / frequencyTenor.Months;
            }
            if (frequencyTenor.Days != 0)
            {
                PaymentsPerYear += 365.0 / frequencyTenor.Days;
            }
            Name = new IdentifierString(String.Format("Simple;{0}", Frequency.Name.String));
        }
Ejemplo n.º 5
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));
 }
Ejemplo n.º 6
0
        public void ToRawYearFraction_7Y3M__1_5()
        {
            TenorTimeSpan tenorTimeSpan = new TenorTimeSpan(7, 3, 0);
            double        actual        = tenorTimeSpan.ToRawYearFraction();

            double expected = 7.25;

            Assert.That(actual, Is.EqualTo(expected).Within(1E-6));
        }
 /// <summary>Gets a <see cref="IndividualDateScheduleFrequency"/> object.
 /// </summary>
 /// <param name="frequencyTenor">The frequency tenor.</param>
 /// <param name="individualDateScheduleFrequency">The individual date schedule frequency (output).</param>
 /// <returns>A value indicating whether <paramref name="individualDateScheduleFrequency"/> contains valid data.</returns>
 internal static bool TryCreate(TenorTimeSpan frequencyTenor, out IDateScheduleFrequency individualDateScheduleFrequency)
 {
     if (TenorTimeSpan.IsNull(frequencyTenor) || (frequencyTenor.IsPositive == false))
     {
         individualDateScheduleFrequency = null;
         return(false);
     }
     individualDateScheduleFrequency = new IndividualDateScheduleFrequency(frequencyTenor);
     return(true);
 }
Ejemplo n.º 8
0
        public void Parse_TestCase(string tenorString, int expectedYears, int expectedMonths, int expectedDays, bool expectedIsPositive, TenorType expectedTenorType)
        {
            TenorTimeSpan actualTenor = TenorTimeSpan.Parse(tenorString);

            Assert.That(actualTenor.Years, Is.EqualTo(expectedYears), "Years component");
            Assert.That(actualTenor.Months, Is.EqualTo(expectedMonths), "Months component");
            Assert.That(actualTenor.Days, Is.EqualTo(expectedDays), "Days component");

            Assert.That(actualTenor.TenorType, Is.EqualTo(expectedTenorType), "Tenor type component");
            Assert.That(actualTenor.IsPositive, Is.EqualTo(expectedIsPositive), "IsPositive component");
        }
        /// <summary>Initializes a new instance of the <see cref="IRCapletTenorConventionConstant"/> class.
        /// </summary>
        /// <param name="liborRateTenor">The (unique) libor rate tenor.</param>
        /// <exception cref="ArgumentException">Thrown, if <paramref name="liborRateTenor"/> represents a tenor leq or equal <c>0</c>.</exception>
        public IRCapletTenorConventionConstant(TenorTimeSpan liborRateTenor)
        {
            if (TenorTimeSpan.IsNull(liborRateTenor) || (liborRateTenor.IsPositive == false))
            {
                throw new ArgumentException("liborRateTenor");
            }
            m_LiborRateTenor = liborRateTenor.AsFrequency();

            m_Name     = new IdentifierString(String.Format("Constant caplet tenor {0}", liborRateTenor.ToString()));
            m_LongName = new IdentifierString(String.Format(IRCapletTenorConventionResources.ConstantTenorLongName, liborRateTenor.ToString()));
        }
        /// <summary>Initializes a new instance of the <see cref="IndividualDateScheduleFrequency"/> class.
        /// </summary>
        /// <param name="frequencyTenor">The frequency tenor.</param>
        /// <exception cref="ArgumentException">Thrown, if <paramref name="frequencyTenor"/> represents a
        /// tenor with a negative sign or the null-tenor.</exception>
        /// <remarks>The <see cref="Name"/> will be set to the <see cref="System.String"/> representation of
        /// <paramref name="frequencyTenor"/>.</remarks>
        public IndividualDateScheduleFrequency(TenorTimeSpan frequencyTenor)
        {
            if (TenorTimeSpan.IsNull(frequencyTenor) || (frequencyTenor.IsPositive == false))
            {
                throw new ArgumentException("frequencyTenor");
            }
            m_FrequencyTenor = frequencyTenor;
            string frequencyTenorAsString = frequencyTenor.ToString();

            m_Name     = new IdentifierString(frequencyTenorAsString);
            m_LongName = new IdentifierString(String.Format(DateFactoryResources.IndividualLongName, frequencyTenorAsString));
        }
Ejemplo n.º 11
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;
            }
Ejemplo n.º 12
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;
            }
 /// <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;
 }
Ejemplo n.º 14
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));
 }
 /// <summary>Gets the tenor of the underlying Libor rate if the tenor is equal for each caplet.
 /// </summary>
 /// <param name="liborTenor">The (unique) tenor of the underlying Libor rate.</param>
 /// <returns>
 /// A value indicating whether <paramref name="liborTenor"/> contains valid data
 /// and a unique tenor is available.
 /// </returns>
 /// <remarks>This method returns the same value as <see cref="IIRCapletTenorConvention.HasUniqueLiborTenor"/>.</remarks>
 public bool TryGetUniqueUnderlyingLiborTenor(out TenorTimeSpan liborTenor)
 {
     liborTenor = m_LiborRateTenor.GetFrequencyTenor();
     return(true);
 }
Ejemplo n.º 16
0
 public TenorTimeSpan GetTimeSpanInBetween_TestCase(DateTime startDate, DateTime endDate, TenorTimeSpan.RoundingRule roundingRule)
 {
     return(TenorTimeSpan.GetTimeSpanInBetween(startDate, endDate, roundingRule));
 }
 public DateTime AddTenorTimeSpan_TestCase(DateTime startDate, TenorTimeSpan tenorTimeSpan, int tenorTimeSpanFactor)
 {
     return(TenorTimeSpanExtensions.AddTenorTimeSpan(startDate, tenorTimeSpan, tenorTimeSpanFactor));
 }
Ejemplo n.º 18
0
        /// <summary>Adds some <see cref="System.DateTime"/> objects into a specific date schedule.
        /// </summary>
        /// <param name="dateSchedule">The date schedule.</param>
        /// <exception cref="NotOperableException">Thrown, if the current instance it not operable.</exception>
        public void AddDatesToDateSchedule(DateSchedule dateSchedule)
        {
            if (IsOperable == false)
            {
                throw new NotOperableException("BackwardDateScheduleRule");
            }
            DateTime firstDate, terminationDate;

            m_TimeSpanDescription.GetStartAndEndDate(m_ReferenceDate, dateSchedule.HolidayCalendar, out firstDate, out terminationDate, dateSchedule.Logging);

            if (terminationDate < firstDate)
            {
                throw new ArgumentException(String.Format(ExceptionMessages.ArgumentOutOfRangeGreaterEqual, "End date [" + terminationDate.ToShortDateString() + "]", "first date [" + firstDate.ToShortDateString() + "]"));
            }
            dateSchedule.Add(terminationDate);  // add the end date

            // gets the date which is used as 'base date' for the date generation loop:
            DateTime seed = terminationDate;

            if ((m_LastRegularDate != null) && (m_LastRegularDate.HasValue))  // 'last regular date' is given
            {
                seed = m_LastRegularDate.Value;
                if (seed > terminationDate)
                {
                    throw new ArgumentException(String.Format(ExceptionMessages.ArgumentOutOfRangeLessEqual, "Last regular date [" + seed.ToShortDateString() + "]", "end date [" + terminationDate.ToShortDateString() + "]"));
                }
            }
            if (m_SeedBusinessDayConvention != null)  // perhaps adjust the 'base date' which is used for the date generation loop
            {
                seed = m_SeedBusinessDayConvention.GetAdjustedDate(seed, dateSchedule.HolidayCalendar);
            }
            else
            {
                seed = m_BusinessDayConvention.GetAdjustedDate(seed, dateSchedule.HolidayCalendar);
            }
            dateSchedule.Add(seed);

            // gets the exit condition for the loop:
            DateTime exitDate = firstDate;  // perhaps not a business day

            if ((m_FirstRegularDate != null) && (m_FirstRegularDate.HasValue))
            {
                exitDate = m_FirstRegularDate.Value;
                if (exitDate > seed)
                {
                    throw new ArgumentException(String.Format(ExceptionMessages.ArgumentOutOfRangeLessEqual, "First regular date [" + exitDate.ToShortDateString() + "]", "last [regular] date [" + seed.ToShortDateString() + "]"));
                }
            }

            if (m_Frequency.IsOnceFrequency())  // end date and seed date are already added
            {
                if (exitDate != firstDate)      // perhaps add the first regular date
                {
                    dateSchedule.Add(exitDate); // one may apply the business day convention to the first regular date
                }
            }
            else  // do the loop with respect to the frequency
            {
                TenorTimeSpan frequencyTenor = m_Frequency.GetFrequencyTenor();
                DateTime      runningDate    = m_BusinessDayConvention.GetAdjustedDate(seed.AddTenorTimeSpan(frequencyTenor), dateSchedule.HolidayCalendar);
                int           periodIndex    = -1;

                while (runningDate >= exitDate)
                {
                    dateSchedule.Add(runningDate);
                    periodIndex--;

                    runningDate = seed.AddTenorTimeSpan(frequencyTenor, periodIndex);
                    runningDate = m_BusinessDayConvention.GetAdjustedDate(runningDate, dateSchedule.HolidayCalendar);
                }
            }
            dateSchedule.Add(firstDate);
        }
Ejemplo n.º 19
0
 /// <summary>Gets the tenor of the underlying Libor rate if the tenor is equal for each caplet.
 /// </summary>
 /// <param name="liborTenor">The (unique) tenor of the underlying Libor rate.</param>
 /// <returns>A value indicating whether <paramref name="liborTenor"/> contains valid data
 /// and a unique tenor is available.
 /// </returns>
 public bool TryGetUniqueUnderlyingLiborTenor(out TenorTimeSpan liborTenor)
 {
     liborTenor = TenorTimeSpan.Null;
     return(false);
 }
 public TenorTimeSpan AddTimeSpan_TestCase(TenorTimeSpan tenorTimeSpan, TenorTimeSpan tenorTimeSpanToAdd, int tenorTimeSpanFactor)
 {
     return(TenorTimeSpanExtensions.AddTimeSpan(tenorTimeSpan, tenorTimeSpanToAdd, tenorTimeSpanFactor));
 }
Ejemplo n.º 21
0
 /// <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));
 }
Ejemplo n.º 22
0
 /// <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));
 }
Ejemplo n.º 23
0
 public bool IsInsideTimeSpan_TestCase(DateTime startDate, TenorTimeSpan tenorTimeSpan, DateTime testDate, int deferredDays)
 {
     return(tenorTimeSpan.IsInsideTimeSpan(startDate, testDate, deferredDays));
 }
Ejemplo n.º 24
0
 /// <summary>Gets the start and end date of the timeframe.
 /// </summary>
 /// <param name="referenceDate">A reference date (can be a business day or a holiday).</param>
 /// <param name="holidayCalendar">The (settlement) holiday calendar.</param>
 /// <param name="fixingLag">The fixing lag, i.e. a method used to calculate the fixing date with respect to the period. Will be applied to the IMM Date (even if the IMM date is not a business day).</param>
 /// <param name="startDate">The start date of the time span with respect to <paramref name="referenceDate"/> (output).</param>
 /// <param name="endDate">The end date of the time span with respect to <paramref name="referenceDate"/> (output).</param>
 /// <param name="tenor">The tenor that represents the time span; if the end date of the current object is not specified by its <see cref="TenorTimeSpan"/> representation, <paramref name="tenorRoundingRule"/>
 /// will be applied to <paramref name="startDate"/> and <paramref name="endDate"/> for the calculation of a <see cref="TenorTimeSpan"/> representation.</param>
 /// <param name="tenorRoundingRule"> A rounding rule which will be take into account if and only if the end date of the current object is not specified by its <see cref="TenorTimeSpan"/> representation.</param>
 /// <param name="logger">An optional logger.</param>
 public DateTime GetStartAndEndDate(DateTime referenceDate, IHolidayCalendar holidayCalendar, IFixingLag fixingLag, out DateTime startDate, out DateTime endDate, out TenorTimeSpan tenor, TenorTimeSpan.RoundingRule tenorRoundingRule = TenorTimeSpan.RoundingRule.NearestMonth, ILogger logger = null)
 {
     tenor = Tenor;
     return(GetStartAndEndDate(referenceDate, holidayCalendar, fixingLag, out startDate, out endDate, logger));
 }
Ejemplo n.º 25
0
 /// <summary>Gets the start and end date of the timeframe.
 /// </summary>
 /// <param name="referenceDate">A reference date (can be a business day or a holiday).</param>
 /// <param name="holidayCalendar">The (settlement) holiday calendar.</param>
 /// <param name="startDate">The start date of the time span with respect to <paramref name="referenceDate"/> (output).</param>
 /// <param name="endDate">The end date of the time span with respect to <paramref name="referenceDate"/> (output).</param>
 /// <param name="tenor">The tenor that represents the time span; if the end date of the current object is not specified by its <see cref="TenorTimeSpan"/> representation, <paramref name="tenorRoundingRule"/>
 /// will be applied to <paramref name="startDate"/> and <paramref name="endDate"/> for the calculation of a <see cref="TenorTimeSpan"/> representation.</param>
 /// <param name="tenorRoundingRule"> A rounding rule which will be take into account if and only if the end date of the current object is not specified by its <see cref="TenorTimeSpan"/> representation.</param>
 /// <param name="logger">An optional logger.</param>
 public void GetStartAndEndDate(DateTime referenceDate, IHolidayCalendar holidayCalendar, out DateTime startDate, out DateTime endDate, out TenorTimeSpan tenor, TenorTimeSpan.RoundingRule tenorRoundingRule = TenorTimeSpan.RoundingRule.NearestMonth, ILogger logger = null)
 {
     tenor = Tenor;
     GetStartAndEndDate(referenceDate, holidayCalendar, out startDate, out endDate, logger);
 }
Ejemplo n.º 26
0
 /// <summary>Determines whether a specified date schedule frequency is the frequency 'once'.
 /// </summary>
 /// <param name="dateScheduleFrequency">The date schedule frequency.</param>
 /// <returns>
 ///     <c>true</c> if the specified date schedule frequency is the frequency 'once'; otherwise, <c>false</c>.
 /// </returns>
 public static bool IsOnceFrequency(this IDateScheduleFrequency dateScheduleFrequency)
 {
     return((dateScheduleFrequency != null) ? TenorTimeSpan.IsNull(dateScheduleFrequency.GetFrequencyTenor()) : false);
 }
Ejemplo n.º 27
0
        public void Parse_TestCase(string tenorTimeSpanSpreadString, bool isTenorTimeSpan, TenorTimeSpan firstTenor, string firstTenorDescription, TenorTimeSpan secondTenor, string secondTenorDescription)
        {
            TenorTimeSpanSpread tenorTimeSpanSpread = TenorTimeSpanSpread.Parse(tenorTimeSpanSpreadString);

            Assert.That(tenorTimeSpanSpread.IsTenorTimeSpan, Is.EqualTo(isTenorTimeSpan), "IsTenorTimeSpan");

            Assert.That(tenorTimeSpanSpread.FirstTenor, Is.EqualTo(firstTenor), "FirstTenor");
            Assert.That(tenorTimeSpanSpread.FirstTenorDescription, Is.EqualTo(firstTenorDescription), "FirstTenorDescription");

            Assert.That(tenorTimeSpanSpread.SecondTenor, Is.EqualTo(secondTenor), "SecondTenor");

            Assert.That(tenorTimeSpanSpread.SecondTenorDescription, Is.EqualTo(secondTenorDescription), "SecondTenorDescription");
        }