示例#1
0
        /// <summary>
        /// Constructor for ZAR market standard, fixed for float 3m Jibar swap.
        /// </summary>
        /// <param name="rate">The fixed rate paid or received</param>
        /// <param name="payFixed">Is the fixed rate paid?</param>
        /// <param name="notional">Flat notional for all dates.</param>
        /// <param name="startDate">First reset date of swap</param>
        /// <param name="tenor">Tenor of swap, must be a whole number of years.</param>
        /// <returns></returns>
        public static IRSwap CreateZARSwap(double rate, bool payFixed, double notional, Date startDate, Tenor tenor)
        {
            IRSwap newSwap  = new IRSwap();
            int    quarters = tenor.years * 4 + tenor.months / 3;

            newSwap.payFixed         = payFixed ? -1 : 1;
            newSwap.indexDates       = new Date[quarters];
            newSwap.paymentDates     = new Date[quarters];
            newSwap.index            = FloatingIndex.JIBAR3M;
            newSwap.spreads          = new double[quarters];;
            newSwap.accrualFractions = new double[quarters];;
            newSwap.notionals        = new double[quarters];
            newSwap.fixedRate        = rate;
            newSwap.ccy         = Currency.ZAR;
            newSwap.indexValues = new double[quarters];

            Date date1 = new Date(startDate);
            Date date2;

            for (int i = 0; i < quarters; i++)
            {
                date2 = startDate.AddMonths(3 * (i + 1));
                newSwap.indexDates[i]       = new Date(date1);
                newSwap.paymentDates[i]     = new Date(date2);
                newSwap.spreads[i]          = 0.0;
                newSwap.accrualFractions[i] = (date2 - date1) / 365.0;
                newSwap.notionals[i]        = notional;
                date1 = new Date(date2);
            }
            return(newSwap);
        }
示例#2
0
        /// <summary>
        /// Creates Bermudan swaption with a simple ZAR swap as underlying, the ZAR swap is the same as that created by:
        ///  <see cref="IRSwap.CreateZARSwap"/>.
        /// </summary>
        /// <param name="exerciseDates">The exercise dates.  The dates on which the person who is long optionality can exercise.</param>
        /// <param name="longOptionality">if set to <c>true</c> then the person valuing this product owns the optionality.</param>
        /// <param name="rate">The fixed rate on the underlying swap.</param>
        /// <param name="payFixed">if set to <c>true</c> then the underlying swap has the person valuaing the product paying fixed after exercise.</param>
        /// <param name="notional">The constant notional in ZAR on the underlying swap.</param>
        /// <param name="startDate">The start date of the underlying swap.</param>
        /// <param name="tenor">The tenor of the underlying swap.</param>
        /// <returns></returns>
        public static BermudanSwaption CreateZARBermudanSwaption(Date[] exerciseDates, bool longOptionality, double rate,
                                                                 bool payFixed, double notional, Date startDate, Tenor tenor)
        {
            IRSwap           swap     = IRSwap.CreateZARSwap(rate, payFixed, notional, startDate, tenor);
            BermudanSwaption swaption = new BermudanSwaption(swap, exerciseDates.ToList(), longOptionality);

            return(swaption);
        }