public double GetForwardRate(Date date)
            {
                Date   endDate  = date.AddTenor(index.tenor);
                double df1      = discountingSource.GetDF(date);
                double df2      = discountingSource.GetDF(endDate);
                double yearFrac = (endDate - date) / 365.0;

                return((df1 / df2 - 1) / yearFrac);
            }
        /// <summary>
        /// </summary>
        /// <param name="date"></param>
        /// <returns></returns>
        public double GetForwardRate(Date date)
        {
            //TODO: Index should store the business day and daycount conventions of the index.
            if (date > discountCurve.GetAnchorDate())
            {
                var df1       = discountCurve.GetDF(date);
                var laterDate = date.AddTenor(index.tenor);
                var df2       = discountCurve.GetDF(laterDate);
                var dt        = (laterDate - date) / 365.0;
                var fwdRate   = (df1 / df2 - 1) / dt;
                return(fwdRate);
            }

            return(fixingCurve.GetForwardRate(date));
        }
Esempio n. 3
0
        /// <summary>
        /// Creates <paramref name="numberOfDates"/> that are <paramref name="periodTenor"/> apart.  The first
        /// date is <paramref name="startDate"/> plus <paramref name="periodTenor"/>.
        /// <para/>
        /// There is no holiday adjustment or stub period.
        /// </summary>
        /// <param name="periodTenor">The period tenor.</param>
        /// <param name="startDate">The start date.</param>
        /// <param name="numberOfDates">The number of dates.</param>
        /// <returns></returns>
        public static void CreateDatesNoHolidays(Tenor periodTenor, Date startDate, int numberOfDates,
                                                 out Date[] paymentDates, out double[] accrualFractions)
        {
            Date runningDate = new Date(startDate);

            paymentDates     = new Date[numberOfDates];
            accrualFractions = new double[numberOfDates];
            Date oldDate = new Date(startDate);

            for (int i = 0; i < numberOfDates; i++)
            {
                runningDate         = runningDate.AddTenor(periodTenor);
                paymentDates[i]     = runningDate;
                accrualFractions[i] = (runningDate - oldDate) / 365.0;
                oldDate             = runningDate;
            }
        }