示例#1
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());
        }
 /// <summary>Initializes a new instance of the <see cref="CurrencyMarketConventions"/> class.
 /// </summary>
 /// <param name="bondMarketConventions">The bond market conventions.</param>
 /// <param name="creditMarketConventions">The credit market conventions.</param>
 /// <param name="inflationMarketConventions">The inflation market conventions.</param>
 /// <param name="moneyMarketConventions">The money market conventions.</param>
 /// <param name="swapMarketConventions">The swap market conventions.</param>
 /// <param name="holidayCalendar">The standard (settlement) holiday calendar.</param>
 /// <exception cref="ArgumentNullException">Thrown, if one of the arguments is <c>null</c>.</exception>
 public CurrencyMarketConventions(ReadOnlyBondMarketConventions bondMarketConventions, ReadOnlyCreditMarketConventions creditMarketConventions, ReadOnlyInflationMarketConventions inflationMarketConventions, ReadOnlyMoneyMarketConventions moneyMarketConventions, ReadOnlySwapMarketConventions swapMarketConventions, IHolidayCalendar holidayCalendar)
     : base(bondMarketConventions, creditMarketConventions, inflationMarketConventions, moneyMarketConventions, swapMarketConventions)
 {
     if (holidayCalendar == null)
     {
         throw new ArgumentNullException("holidayCalendar");
     }
     m_HolidayCalendar = holidayCalendar;
 }