Пример #1
0
 public static object _CreateZARBermudanSwaption(string objectName,
                                                 object[,] exerciseDates,
                                                 object[,] longOptionality,
                                                 object[,] startDate,
                                                 object[,] tenor,
                                                 object[,] rate,
                                                 object[,] payFixed,
                                                 object[,] notional)
 {
     try
     {
         Date[]           _exerciseDates   = XU.GetDate1D(exerciseDates, "exerciseDates");
         Boolean          _longOptionality = XU.GetBoolean0D(longOptionality, "longOptionality");
         Date             _startDate       = XU.GetDate0D(startDate, "startDate");
         Tenor            _tenor           = XU.GetTenor0D(tenor, "tenor");
         Double           _rate            = XU.GetDouble0D(rate, "rate");
         Boolean          _payFixed        = XU.GetBoolean0D(payFixed, "payFixed");
         Double           _notional        = XU.GetDouble0D(notional, "notional");
         BermudanSwaption _result          = XLRates.CreateZARBermudanSwaption(_exerciseDates, _longOptionality, _startDate, _tenor, _rate, _payFixed, _notional);
         return(XU.AddObject(objectName, _result));
     }
     catch (Exception e)
     {
         return(XU.Error0D(e));
     }
 }
Пример #2
0
        public void TestBermudanSwaptionPV()
        {
            var coordinator = new Coordinator(hullWiteSim, new List <Simulator>(), 5000);

            BermudanSwaption bermudan;

            bermudan = new BermudanSwaption(swapPay, exDates.GetRange(0, 1), true);
            var value1 = coordinator.Value(new Product[] { bermudan }, valueDate);

            bermudan = new BermudanSwaption(swapPay, exDates.GetRange(0, 2), true);
            var value2 = coordinator.Value(new Product[] { bermudan }, valueDate);

            bermudan = new BermudanSwaption(swapPay, exDates.GetRange(0, 3), true);
            var value3 = coordinator.Value(new Product[] { bermudan }, valueDate);

            Assert.IsTrue(value1 < value2, "Bermudan with 1 exercise date must be worth less than one with 2.");
            Assert.IsTrue(value2 < value3, "Bermudan with 2 exercise dates must be worth less than one with 3.");

            /*
             * Date endDate = valueDate.AddTenor(tenor);
             * List<Date> fwdValueDates = new List<Date>();
             * while (date < endDate)
             * {
             *  fwdValueDates.Add(date);
             *  date = date.AddTenor(Tenor.Days(10));
             * }
             * double[] epe = coordinator.EPE(new Product[] { swap }, valueDate, fwdValueDates.ToArray());
             */
        }
Пример #3
0
        /// <summary>
        /// Creates Bermudan swaption with a simple ZAR swap as underlying, the ZAR swap is the same as that created by:
        ///  <see cref="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 valuing 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>
        /// <param name="floatRateIndex"></param>
        /// <returns></returns>
        public static BermudanSwaption CreateZARBermudanSwaption(Date[] exerciseDates, bool longOptionality,
                                                                 double rate,
                                                                 bool payFixed, double notional, Date startDate, Tenor tenor, FloatRateIndex floatRateIndex)
        {
            var swap     = CreateZARSwap(rate, payFixed, notional, startDate, tenor, floatRateIndex);
            var swaption = new BermudanSwaption(swap, exerciseDates.ToList(), longOptionality);

            return(swaption);
        }
Пример #4
0
 public static BermudanSwaption CreateZARBermudanSwaption([ExcelArgument(Description = "The exercise dates.  The dates on which the person who is long optionality can exercise.")] Date[] exerciseDates,
                                                          [ExcelArgument(Description = "if set to TRUE then the person valuing this product owns the optionality.")] bool longOptionality,
                                                          [ExcelArgument(Description = "First reset date of the underlying swap.")] Date startDate,
                                                          [ExcelArgument(Description = "Tenor of underlying swap, must be a whole number of years.  Example '5Y'.")] Tenor tenor,
                                                          [ExcelArgument(Description = "The fixed rate paid or received on the underlying swap.")] double rate,
                                                          [ExcelArgument(Description = "Is the fixed rate paid? Enter 'TRUE' for yes.")] bool payFixed,
                                                          [ExcelArgument(Description = "Flat notional for all dates.")] double notional)
 {
     return(BermudanSwaption.CreateZARBermudanSwaption(exerciseDates, longOptionality, rate, payFixed, notional, startDate, tenor));
 }
Пример #5
0
        public void TestBermudanSwaptionPVLongAndShort()
        {
            var coordinator = new Coordinator(hullWiteSim, new List <Simulator>(), 5000);

            var bermudan1 = new BermudanSwaption(swapPay, exDates.GetRange(0, 1), true);
            var value1    = coordinator.Value(new Product[] { bermudan1 }, valueDate);
            var bermudan2 = new BermudanSwaption(swapRec, exDates.GetRange(0, 1), false);
            var value2    = coordinator.Value(new Product[] { bermudan2 }, valueDate);
            var value3    = coordinator.Value(new Product[] { bermudan1, bermudan2 }, valueDate);

            //Assert.IsTrue(value1 < value2, "Bermudan with 1 exercise date must be worth less than one with 2.");
            //            Assert.IsTrue(value2 < value3, "Bermudan with 2 exercise dates must be worth less than one with 3.");
        }
Пример #6
0
        public void TestPhysicalSwaptionEPE()
        {
            Coordinator coordinator = new Coordinator(hullWiteSim, new List <Simulator>(), 5000);
            List <Date> exDate      = new List <Date> {
                new Date(2018, 9, 17)
            };
            // Couterparty has option to enter into a receive fixed swap
            BermudanSwaption physicalSwaption = new BermudanSwaption(swapPay, exDate, false);

            Date        date          = valueDate;
            Date        endDate       = valueDate.AddTenor(new Tenor(0, 0, 3, 5));
            List <Date> fwdValueDates = new List <Date>();

            while (date <= endDate)
            {
                fwdValueDates.Add(date);
                date = date.AddTenor(Tenor.Days(10));
            }
            double[] epe = coordinator.EPE(new Product[] { physicalSwaption }, valueDate, fwdValueDates.ToArray());
            //Debug.WriteToFile(@"c:\dev\temp\ene_physicalswaption_HW.csv", epe);
        }