コード例 #1
0
        /// <summary>
        /// Computes the shifted quarterly cash forward rate for a specific future time.
        /// </summary>
        /// <param name="forwardDate"></param>
        /// <param name="discount">Discount factors used.</param>
        /// <param name="shift">Shifts used.</param>
        /// <returns></returns>
        public static double ShiftedCashForwardRate(int forwardDate, QuarterlyDiscounts discount, QuarterlyShifts shift)
        {
            double rate = 4 * (discount.Get(forwardDate) / discount.Get(forwardDate + 1) - 1);

            rate += shift.Get(forwardDate);
            return(rate);
        }
コード例 #2
0
        /// <summary>
        /// The "shift" of the swap rate, or shifted swap rate - actual swap rate.
        /// </summary>
        /// <param name="expiry"></param>
        /// <param name="tenor"></param>
        /// <param name="discount"></param>
        /// <param name="shift"></param>
        /// <returns></returns>
        public static double SwapShift(int expiry, int tenor, QuarterlyDiscounts discount, QuarterlyShifts shift)
        {
            double numerator   = 0;
            double denominator = 0;

            for (int i = 0; i < tenor; i++)
            {
                double forward = ForwardContract(expiry, expiry + i + 1, discount);
                numerator   += forward * shift.Get(expiry + i);
                denominator += forward;
            }
            return(numerator / denominator);
        }