/// <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)); }
/// <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>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>Sets the frequency of the floating rate leg and sets the <see cref="FloatingFrequencyState"/> to <see cref="ConventionState.StandardValue"/>. /// </summary> /// <param name="floatingFrequency">The frequency of the floating rate leg.</param> internal void SetStandardFloatingFrequency(IDateScheduleFrequency floatingFrequency) { if (floatingFrequency == null) { throw new ArgumentNullException("floatingFrequency"); } m_FloatingFrequency = floatingFrequency; m_FloatingFrequencyState = ConventionState.StandardValue; }
/// <summary>Sets the coupon frequency and sets the <see cref="CouponFrequencyState"/> to <see cref="ConventionState.StandardValue"/>. /// </summary> /// <param name="couponFrequency">The Bond coupon frequency.</param> internal void SetStandardCouponFrequency(IDateScheduleFrequency couponFrequency) { if (couponFrequency == null) { throw new ArgumentNullException("couponFrequency"); } m_CouponFrequency = couponFrequency; m_CouponFrequencyState = ConventionState.StandardValue; }
/// <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); }
/// <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="InflationBondConventions"/> class. /// </summary> /// <param name="bondMarketConventions">The bond market conventions.</param> /// <exception cref="ArgumentNullException">Thrown, if <paramref name="bondMarketConventions"/> is <c>null</c>.</exception> /// <exception cref="ArgumentException">Thrown, if <paramref name="bondMarketConventions"/> is not completely defined.</exception> public InflationBondConventions(InflationMarketConventions.InflationBondConventions bondMarketConventions) { if (bondMarketConventions == null) { throw new ArgumentNullException("bondMarketConventions"); } if (bondMarketConventions.IsCompletelyDefined == false) { throw new ArgumentException(String.Format(ExceptionMessages.ArgumentIsNotWellDefined, "Bond market conventions"), "bondMarketConventions"); } BusinessDayConvention = bondMarketConventions.BusinessDayConvention; CouponFrequency = bondMarketConventions.CouponFrequency; DayCountConvention = bondMarketConventions.DayCountConvention; }
/// <summary>Initializes a new instance of the <see cref="InflationSwapConventions"/> class. /// </summary> /// <param name="swapMarketConventions">The swap market conventions.</param> public InflationSwapConventions(InflationMarketConventions.InflationSwapConventions swapMarketConventions) { if (swapMarketConventions == null) { throw new ArgumentNullException("swapMarketConventions"); } if (swapMarketConventions.IsCompletelyDefined == false) { throw new ArgumentException(String.Format(ExceptionMessages.ArgumentIsNotWellDefined, "Inflation-linked Swap market conventions"), "swapMarketConventions"); } BusinessDaysToSettle = swapMarketConventions.BusinessDaysToSettle.Value; FixedBusinessDayConvention = swapMarketConventions.FixedBusinessDayConvention; FixedDayCountConvention = swapMarketConventions.FixedDayCountConvention; FixedFrequency = swapMarketConventions.FixedFrequency; FloatingBusinessDayConvention = swapMarketConventions.FloatingBusinessDayConvention; FloatingDayCountConvention = swapMarketConventions.FloatingDayCountConvention; FloatingFrequency = swapMarketConventions.FloatingFrequency; }
/// <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; }
/// <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); }
/// <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)); }
/// <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; }
/// <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); }