Example #1
0
        public static double ValueSwap(IRSwap swap, Date valueDate, IDiscountingSource curve)
        {
            // Get the required objects off the map
            var index = swap.GetFloatingIndex();

            // Calculate the first fixing off the curve to use at all past dates.
            var df1       = curve.GetDF(valueDate);
            var laterDate = valueDate.AddTenor(index.Tenor);
            var df2       = curve.GetDF(laterDate);
            var dt        = (laterDate - valueDate) / 365.0;
            var rate      = (df1 / df2 - 1) / dt;

            //Set up the valuation engine.
            IFloatingRateSource forecastCurve = new ForecastCurveFromDiscount(curve, index,
                                                                              new FloatingRateFixingCurve1Rate(valueDate, rate, index));
            var curveSim = new DeterministicCurves(curve);

            curveSim.AddRateForecast(forecastCurve);
            var coordinator = new Coordinator(curveSim, new List <Simulator>(), 1);

            // Run the valuation
            var value = coordinator.Value(new Product[] { swap }, valueDate);

            return(value);
        }
Example #2
0
        public void TestCoordinatorAllData()
        {
            // Make the swap
            var    rate      = 0.07;
            var    payFixed  = true;
            double notional  = 1000000;
            var    startDate = new Date(2016, 9, 17);
            var    tenor     = Tenor.Years(5);
            var    swap      = IRSwap.CreateZARSwap(rate, payFixed, notional, startDate, tenor);

            // Set up the model
            var valueDate     = new Date(2016, 9, 17);
            var a             = 0.05;
            var vol           = 0.01;
            var flatCurveRate = 0.07;
            var hullWiteSim   = new HullWhite1F(Currency.ZAR, a, vol, flatCurveRate, flatCurveRate, valueDate);

            hullWiteSim.AddForecast(FloatingIndex.JIBAR3M);
            var coordinator = new Coordinator(hullWiteSim, new List <Simulator>(), 5000);

            var date          = valueDate;
            var endDate       = valueDate.AddTenor(tenor);
            var fwdValueDates = new List <Date>();

            while (date < endDate)
            {
                fwdValueDates.Add(date);
                date = date.AddTenor(Tenor.Days(10));
            }

            var allDetails = coordinator.GetValuePaths(new Product[] { swap }, valueDate, fwdValueDates.ToArray());

            allDetails.GetNames();
        }
Example #3
0
        public static double ValueZARSwap1Curve([ExcelArgument(Description = "The name of the swap.")] IRSwap swap,
                                                [ExcelArgument(Description = "The date on which valuation is required.  Cannot be before the anchor date of the curve.")] Date valueDate,
                                                [ExcelArgument(Description = "The discounting curve.  Will also be used for forecasting Jibar and providing the most recent required Jibar fix.")] IDiscountingSource curve)
        {
            // Get the required objects off the map
            FloatingIndex index = swap.GetFloatingIndex();

            // Calculate the first fixing off the curve to use at all past dates.
            double df1       = curve.GetDF(valueDate);
            Date   laterDate = valueDate.AddTenor(index.tenor);
            double df2       = curve.GetDF(laterDate);
            double dt        = (laterDate - valueDate) / 365.0;
            double rate      = (df1 / df2 - 1) / dt;

            //Set up the valuation engine.
            IFloatingRateSource forecastCurve = new ForecastCurveFromDiscount(curve, index,
                                                                              new FloatingRateFixingCurve1Rate(rate, index));
            DeterminsiticCurves curveSim = new DeterminsiticCurves(curve);

            curveSim.AddRateForecast(forecastCurve);
            Coordinator coordinator = new Coordinator(curveSim, new List <Simulator>(), 1);

            // Run the valuation
            double value = coordinator.Value(new Product[] { swap }, valueDate);

            return(value);
        }
Example #4
0
        private Product[] GetListOfSwaps()
        {
            int    N          = 50000;
            Date   anchorDate = new Date(2016, 11, 21);
            double rate       = 0.08;
            bool   payFixed   = true;
            double notional   = 1000000;

            double[,] swapDist = new double[, ] {
                { 0.171 }, { 0.148 }, { 0.101 }, { 0.094 }, { 0.108 }, { 0.056 }, { 0.041 }, { 0.049 }, { 0.047 }, { 0.056 }, { 0.013 }, { 0.013 }, { 0.010 }, { 0.011 }, { 0.011 }, { 0.004 }, { 0.003 }, { 0.005 }, { 0.007 }, { 0.006 }, { 0.004 }, { 0.004 }, { 0.007 }, { 0.005 }, { 0.006 }, { 0.006 }, { 0.003 }, { 0.003 }, { 0.002 }, { 0.005 }
            };
            IRandomNumberGenerator <double> generator1   = new ZigguratUniformGenerator(0, 1);
            IRandomNumberGenerator <double> generator365 = new ZigguratUniformGenerator(1, 365);

            double[,] cumSum = swapDist.CumulativeSum(1);

            Product[] allSwaps = new Product[N];
            for (int swapNum = 0; swapNum < N; swapNum++)
            {
                double x     = generator1.Generate();
                int    years = 0;
                while (years < cumSum.GetLength(0) && x > cumSum[years, 0])
                {
                    years++;
                }
                int  days      = (int)Math.Round(generator365.Generate());
                Date endDate   = anchorDate.AddTenor(new Tenor(days, 0, 0, years));
                Date startDate = endDate.AddTenor(Tenor.Years(-years - 1));
                allSwaps[swapNum] = IRSwap.CreateZARSwap(rate, payFixed, notional, startDate, Tenor.Years(years + 1));
            }

            return(allSwaps);
        }
Example #5
0
        public void SetCalibrationDate(Date calibrationDate)
        {
            _calibrationDate = calibrationDate;
            _maturityDate    = calibrationDate.AddTenor(_tenor);
            var yf = Actual365Fixed.Instance.YearFraction(_calibrationDate, _maturityDate);

            _cf = 1e6 * (1 + _simpleRate * yf);
        }
Example #6
0
        public static HullWhite1F CreateHWModelDemo([ExcelArgument(Description = "The constant rate of mean reversion.")] double meanReversion,
                                                    [ExcelArgument(Description = "The constant short rate volatility.  Note that this is a Gaussian vol and will in general be lower than the vol that would be used in Black.")] double flatVol,
                                                    [ExcelArgument(Description = "The curve to which zero coupon bond prices will be calibrated.")] IDiscountingSource baseCurve,
                                                    [ExcelArgument(Description = "The indices that should be forecast with this same cuve.  No spreads are added.")] FloatingIndex forecastIndices)
        {
            Date        anchorDate    = baseCurve.GetAnchorDate();
            double      flatCurveRate = -Math.Log(baseCurve.GetDF(anchorDate.AddTenor(Tenor.Years(1))));
            HullWhite1F model         = new HullWhite1F(baseCurve.GetCurrency(), meanReversion, flatVol, flatCurveRate, flatCurveRate, anchorDate);

            model.AddForecast(forecastIndices);
            return(model);
        }
Example #7
0
        public override double[] GetUnderlyingFactors(Date date)
        {
            double[] regressors = new double[3];
            double   fxRate     = GetIndices(currencyPair, new List <Date> {
                date
            })[0];
            double defaultIndicator = date < simDefaultTime ? 0.0 : 1.0;
            double fwdDefaultP      = (1.0 - survivalProbSource.GetSP(date.AddTenor(Tenor.Years(1))) / survivalProbSource.GetSP(date));

            regressors[0] = fxRate;
            regressors[1] = defaultIndicator;
            regressors[2] = fwdDefaultP;
            return(regressors);
        }
Example #8
0
        public void TestQuantoCDS()
        {
            var spot = 1.00;
            var relJumpSizeInDefault = -0.2;
            var cdsSpread            = 0.025;
            // Trades
            var anchorDate = new Date(2016, 11, 25);
            var refEntity  = new ReferenceEntity("ABC");

            Date[]   paymentDates;
            double[] accrualFractions;
            DateGenerators.CreateDatesNoHolidays(Tenor.Months(3), anchorDate, 20, out paymentDates,
                                                 out accrualFractions);
            var zarNotionals     = Vector.Ones(paymentDates.Length).Multiply(1000000.0);
            var usdNotionals     = zarNotionals.Divide(spot);
            var zarSpreads       = Vector.Ones(paymentDates.Length).Multiply(cdsSpread);
            var usdSpreads       = zarSpreads.Multiply(1 + relJumpSizeInDefault); // Adjusted for the FX jump size.
            var boughtProtection = true;

            var cdsZAR = new CDS(refEntity, Currency.ZAR, paymentDates, zarNotionals, zarSpreads, accrualFractions,
                                 boughtProtection);
            var cdsUSD = new CDS(refEntity, Currency.USD, paymentDates, zarNotionals, usdSpreads, accrualFractions,
                                 boughtProtection);

            // Model
            var curveDates       = new[] { anchorDate, anchorDate.AddTenor(Tenor.Years(10)) };
            var expectedRecovery = 0.4;
            var hazardRates      = new[] { cdsSpread / (1 - expectedRecovery), cdsSpread / (1 - expectedRecovery) };
            var usdRates         = new[] { 0.01, 0.02 };
            var zarRates         = new[] { 0.07, 0.08 };
            IDiscountingSource         usdDiscountCurve = new DatesAndRates(Currency.USD, anchorDate, curveDates, usdRates);
            IDiscountingSource         zarDiscountCurve = new DatesAndRates(Currency.ZAR, anchorDate, curveDates, zarRates);
            ISurvivalProbabilitySource abcHazardCurve   = new HazardCurve(refEntity, anchorDate, curveDates, hazardRates);
            var otherCurrency = Currency.USD;

            var fxSource             = new FXForecastCurve(otherCurrency, Currency.ZAR, spot, usdDiscountCurve, zarDiscountCurve);
            var fxVol                = 0.15;
            NumeraireSimulator model = new DeterministicCreditWithFXJump(abcHazardCurve, otherCurrency, fxSource,
                                                                         zarDiscountCurve, fxVol, relJumpSizeInDefault, expectedRecovery);

            // Valuation
            var N        = 5000;
            var coord    = new Coordinator(model, new List <Simulator>(), N);
            var zarValue = coord.Value(new Product[] { cdsZAR }, anchorDate);
            var usdValue = coord.Value(new Product[] { cdsUSD }, anchorDate);

            Assert.AreEqual(0.0, zarValue, 800.0); // about 2bp
            Assert.AreEqual(0.0, usdValue, 800.0); // about 2bp
        }
Example #9
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)
 {
     var runningDate = new Date(startDate);
     paymentDates = new Date[numberOfDates];
     accrualFractions = new double[numberOfDates];
     var oldDate = new Date(startDate);
     for (var i = 0; i < numberOfDates; i++)
     {
         runningDate = runningDate.AddTenor(periodTenor);
         paymentDates[i] = runningDate;
         accrualFractions[i] = (runningDate - oldDate) / 365.0;
         oldDate = runningDate;
     }
 }
        public override double[] GetUnderlyingFactors(Date date)
        {
            var regressors = new double[3];
            var fxRate     = GetIndices(_currencyPair, new List <Date> {
                date
            })[0];
            var defaultIndicator = date < _simDefaultTime ? 0.0 : 1.0;
            var fwdDefaultP      = 1.0 - _survivalProbSource.GetSP(date.AddTenor(Tenor.FromYears(1))) /
                                   _survivalProbSource.GetSP(date);

            regressors[0] = fxRate;
            regressors[1] = defaultIndicator;
            regressors[2] = fwdDefaultP;
            return(regressors);
        }
        /// <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));
        }
Example #12
0
        public void TestQuantoCDS()
        {
            var spot = 1.00;
            var relJumpSizeInDefault = -0.2;
            var cdsSpread            = 0.025;
            // Trades
            var anchorDate = new Date(2016, 11, 25);
            var refEntity  = TestHelpers.TestCp;

            DateGenerators.CreateDatesNoHolidays(Tenor.FromMonths(3), anchorDate, 20, out var paymentDates,
                                                 out var accrualFractions);
            var zarNotionals     = Vector.Ones(paymentDates.Length).Multiply(1000000.0);
            var zarSpreads       = Vector.Ones(paymentDates.Length).Multiply(cdsSpread);
            var usdSpreads       = zarSpreads.Multiply(1 + relJumpSizeInDefault); // Adjusted for the FX jump size.
            var boughtProtection = true;

            var cdsZAR = new CDS(refEntity, TestHelpers.ZAR, paymentDates, zarNotionals, zarSpreads, accrualFractions,
                                 boughtProtection);
            var cdsUSD = new CDS(refEntity, TestHelpers.USD, paymentDates, zarNotionals, usdSpreads, accrualFractions,
                                 boughtProtection);

            // Model
            var curveDates       = new[] { anchorDate, anchorDate.AddTenor(Tenor.FromYears(10)) };
            var expectedRecovery = 0.4;
            var hazardRates      = new[] { cdsSpread / (1 - expectedRecovery), cdsSpread / (1 - expectedRecovery) };
            var usdRates         = new[] { 0.01, 0.02 };
            var zarRates         = new[] { 0.07, 0.08 };
            var usdDiscountCurve = new DatesAndRates(TestHelpers.USD, anchorDate, curveDates, usdRates);
            var zarDiscountCurve = new DatesAndRates(TestHelpers.ZAR, anchorDate, curveDates, zarRates);
            var abcHazardCurve   = new HazardCurve(refEntity, anchorDate, curveDates, hazardRates);

            var fxSource = new FXForecastCurve(TestHelpers.USDZAR, spot, usdDiscountCurve, zarDiscountCurve);
            var fxVol    = 0.15;
            var model    = new DeterministicCreditWithFXJump(abcHazardCurve, TestHelpers.USDZAR, fxSource,
                                                             zarDiscountCurve, fxVol, relJumpSizeInDefault, expectedRecovery);

            // Valuation
            var N        = 5000;
            var coord    = new Coordinator(model, new List <Simulator>(), N);
            var zarValue = coord.Value(new[] { cdsZAR }, anchorDate);
            var usdValue = coord.Value(new[] { cdsUSD }, anchorDate);

            Assert.AreEqual(0.0, zarValue, 800.0); // about 2bp
            Assert.AreEqual(0.0, usdValue, 800.0); // about 2bp
        }
Example #13
0
 /// <summary>
 /// Creates dates that are <paramref name="periodTenor" /> apart.  The first
 /// date is <paramref name="startDate" /> the last date payment date is the first rolled date on or after
 /// <paramref name="startDate" /> plus <paramref name="endTenor" />.
 /// <para />
 /// There is no holiday adjustment or stub period.
 /// </summary>
 /// <param name="startDate">The start date.</param>
 /// <param name="endTenor"></param>
 /// <param name="periodTenor">The period tenor.</param>
 /// <returns></returns>
 public static void CreateDatesNoHolidays(Date startDate, Tenor endTenor, Tenor periodTenor,
     out List<Date> resetDates, out List<Date> paymentDates, out List<double> accrualFractions)
 {
     var dayCount = Actual365Fixed.Instance;
     resetDates = new List<Date>();
     paymentDates = new List<Date>();
     accrualFractions = new List<double>();
     var endDate = startDate.AddTenor(endTenor);
     var resetDate = new Date(startDate);
     var paymentDate = resetDate.AddTenor(periodTenor);
     while (paymentDate <= endDate)
     {
         resetDates.Add(resetDate);
         paymentDates.Add(paymentDate);
         accrualFractions.Add(dayCount.YearFraction(resetDate, paymentDate));
         resetDate = new Date(paymentDate);
         paymentDate = resetDate.AddTenor(periodTenor);
     }
 }
Example #14
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);
        }
Example #15
0
        public void TestCoordinatorEPESwap()
        {
            // Make the swap
            var    rate      = 0.07;
            var    payFixed  = true;
            double notional  = 1000000;
            var    startDate = new Date(2016, 9, 17);
            var    tenor     = Tenor.FromYears(5);
            var    swap      = TestHelpers.CreateZARSwap(rate, payFixed, notional, startDate, tenor, TestHelpers.Jibar3M);

            // Set up the model
            var valueDate     = new Date(2016, 9, 17);
            var a             = 0.05;
            var vol           = 0.005;
            var flatCurveRate = 0.07;
            var hullWiteSim   = new HullWhite1F(TestHelpers.ZAR, a, vol, flatCurveRate, flatCurveRate);

            hullWiteSim.AddForecast(TestHelpers.Jibar3M);
            var coordinator = new Coordinator(hullWiteSim, new List <Simulator>(), 5000);

            var date          = valueDate;
            var endDate       = valueDate.AddTenor(tenor);
            var fwdValueDates = new List <Date>();

            while (date < endDate)
            {
                fwdValueDates.Add(date);
                date = date.AddTenor(Tenor.FromDays(10));
            }

            var epe = coordinator.EPE(new Product[] { swap }, valueDate, fwdValueDates.ToArray());

            //Debug.WriteToFile(@"c:\dev\temp\epe_rate08_vol005.csv", epe);

            Assert.AreEqual(2560, epe[0], 100.0);
            Assert.AreEqual(6630, epe[90], 100.0);
            Assert.AreEqual(734, epe[182], 30);
        }
Example #16
0
        public void TestCoordinatorEPESwap()
        {
            // Make the swap
            double rate      = 0.07;
            bool   payFixed  = true;
            double notional  = 1000000;
            Date   startDate = new Date(2016, 9, 17);
            Tenor  tenor     = Tenor.Years(5);
            IRSwap swap      = IRSwap.CreateZARSwap(rate, payFixed, notional, startDate, tenor);

            // Set up the model
            Date        valueDate     = new Date(2016, 9, 17);
            double      a             = 0.05;
            double      vol           = 0.005;
            double      flatCurveRate = 0.07;
            HullWhite1F hullWiteSim   = new HullWhite1F(Currency.ZAR, a, vol, flatCurveRate, flatCurveRate, valueDate);

            hullWiteSim.AddForecast(FloatingIndex.JIBAR3M);
            Coordinator coordinator = new Coordinator(hullWiteSim, new List <Simulator>(), 5000);

            Date        date          = valueDate;
            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());
            //Debug.WriteToFile(@"c:\dev\temp\epe_rate08_vol005.csv", epe);

            Assert.AreEqual(2560, epe[0], 100.0);
            Assert.AreEqual(6630, epe[90], 100.0);
            Assert.AreEqual(734, epe[182], 30);
        }
Example #17
0
        private Product[] GetListOfSwaps()
        {
            var    N          = 50000;
            var    anchorDate = new Date(2016, 11, 21);
            var    rate       = 0.08;
            var    payFixed   = true;
            double notional   = 1000000;

            var swapDist = new[, ]
            {
                { 0.171 }, { 0.148 }, { 0.101 }, { 0.094 }, { 0.108 }, { 0.056 }, { 0.041 }, { 0.049 }, { 0.047 }, { 0.056 }, { 0.013 },
                { 0.013 }, { 0.010 }, { 0.011 }, { 0.011 }, { 0.004 }, { 0.003 }, { 0.005 }, { 0.007 }, { 0.006 }, { 0.004 }, { 0.004 },
                { 0.007 }, { 0.005 }, { 0.006 }, { 0.006 }, { 0.003 }, { 0.003 }, { 0.002 }, { 0.005 }
            };
            IRandomNumberGenerator <double> generator1   = new ZigguratUniformGenerator(0, 1);
            IRandomNumberGenerator <double> generator365 = new ZigguratUniformGenerator(1, 365);
            var cumSum = swapDist.CumulativeSum(1);

            var allSwaps = new Product[N];

            for (var swapNum = 0; swapNum < N; swapNum++)
            {
                var x     = generator1.Generate();
                var years = 0;
                while (years < cumSum.GetLength(0) && x > cumSum[years, 0])
                {
                    years++;
                }
                var days      = (int)Math.Round(generator365.Generate());
                var endDate   = anchorDate.AddTenor(new Tenor(days, 0, 0, years));
                var startDate = endDate.AddTenor(Tenor.FromYears(-years - 1));
                allSwaps[swapNum] = TestHelpers.CreateZARSwap(rate, payFixed, notional, startDate, Tenor.FromYears(years + 1), TestHelpers.Jibar3M);
            }

            return(allSwaps);
        }
 public void SetCalibrationDate(Date calibrationDate)
 {
     _startDate = calibrationDate.AddTenor(_startTenor);
     _endDate   = calibrationDate.AddTenor(_endTenor);
 }
Example #19
0
        public static AssetSwap CreateAssetSwap(double payFixed, BesaJseBond besaJseBond, Date settleDate, FloatRateIndex index, double spread, Calendar calendar, Currency ccy, IDiscountingSource discountCurve)
        {
            //Design floating leg inputs
            var dayCount = Actual365Fixed.Instance;
            var unAdjResetDatesFloating   = new List <Date>();
            var unAdjPaymentDatesFloating = new List <Date>();
            var resetDatesFloating        = new List <Date>();
            var paymentDatesFloating      = new List <Date>();
            var accrualFractions          = new List <double>();
            var endDate             = besaJseBond.maturityDate;
            var paymentDateFloating = new Date(endDate);
            var resetDateFloating   = paymentDateFloating.SubtractTenor(index.Tenor);

            while (resetDateFloating >= settleDate)
            {
                unAdjPaymentDatesFloating.Add(paymentDateFloating);
                unAdjResetDatesFloating.Add(resetDateFloating);
                resetDatesFloating.Add(BusinessDayStore.ModifiedFollowing.Adjust(resetDateFloating, calendar));
                paymentDatesFloating.Add(BusinessDayStore.ModifiedFollowing.Adjust(paymentDateFloating, calendar));
                accrualFractions.Add(dayCount.YearFraction(BusinessDayStore.ModifiedFollowing.Adjust(resetDateFloating, calendar),
                                                           BusinessDayStore.ModifiedFollowing.Adjust(paymentDateFloating, calendar)));
                paymentDateFloating = new Date(resetDateFloating);
                resetDateFloating   = paymentDateFloating.SubtractTenor(index.Tenor);
            }

            resetDatesFloating.Reverse();
            paymentDatesFloating.Reverse();
            accrualFractions.Reverse();

            resetDatesFloating[0] = new Date(settleDate);
            var firstResetDate   = resetDatesFloating.First();
            var firstPaymentDate = paymentDatesFloating.First();

            accrualFractions[0] = dayCount.YearFraction(firstResetDate, firstPaymentDate);

            //Design Fixed leg inputs
            var unAdjPaymentDatesFixed = new List <Date>();
            var paymentDatesFixed      = new List <Date>();

            var thisYearCpn1 = new Date(settleDate.Year, besaJseBond.couponMonth1, besaJseBond.couponDay1);
            var thisYearCpn2 = new Date(settleDate.Year, besaJseBond.couponMonth2, besaJseBond.couponDay2);
            var lastYearCpn2 = new Date(settleDate.Year - 1, besaJseBond.couponMonth2, besaJseBond.couponDay2);

            Date lcd; //lcd stands for last coupon date

            if (settleDate > thisYearCpn2)
            {
                lcd = new Date(thisYearCpn2.Year, thisYearCpn2.Month, thisYearCpn2.Day);
            }
            if (settleDate > thisYearCpn1)
            {
                lcd = new Date(thisYearCpn1.Year, thisYearCpn1.Month, thisYearCpn1.Day);
            }
            lcd = new Date(lastYearCpn2.Year, lastYearCpn2.Month, lastYearCpn2.Day);

            Date ncd; //ncd stands for next coupon date

            if (lcd.Month == besaJseBond.couponMonth2)
            {
                ncd = new Date(lcd.Year + 1, besaJseBond.couponMonth1, besaJseBond.couponDay1);
            }
            else
            {
                ncd = new Date(lcd.Year, besaJseBond.couponMonth2, besaJseBond.couponDay2);
            }

            var paymentDateFixed = new Date(ncd.AddTenor(Tenor.FromMonths(6)));

            while (paymentDateFixed <= endDate)
            {
                unAdjPaymentDatesFixed.Add(paymentDateFixed);
                paymentDatesFixed.Add(BusinessDayStore.ModifiedFollowing.Adjust(paymentDateFixed, calendar));
                paymentDateFixed = paymentDateFixed.AddTenor(Tenor.FromMonths(6));
            }

            //create new instance of asset swap
            var assetSwap = new AssetSwap(payFixed, index, besaJseBond, resetDatesFloating, paymentDatesFloating, paymentDatesFixed, spread,
                                          accrualFractions, calendar, ccy);

            //Create trade date of the swap
            var effectiveDateDays = 3;
            var unAdjTradeDate    = settleDate.AddDays(-effectiveDateDays);
            var tradeDate         = BusinessDayStore.ModifiedFollowing.Adjust(unAdjTradeDate, assetSwap.zaCalendar);

            //Set value date
            assetSwap.SetValueDate(tradeDate);

            // Calculate the first fixing off the curve to use at all past dates.
            var df1       = discountCurve.GetDF(tradeDate);
            var laterDate = tradeDate.AddTenor(assetSwap.index.Tenor);
            var df2       = discountCurve.GetDF(laterDate);
            var dt        = (laterDate - tradeDate) / 365.0;
            var rate      = (df1 / df2 - 1) / dt;

            // Create the forecast curve from the discount curve
            IFloatingRateSource forecastCurve = new ForecastCurveFromDiscount(discountCurve, assetSwap.index,
                                                                              new FloatingRateFixingCurve1Rate(tradeDate, rate, assetSwap.index));

            //Setting index values
            var indexValues = new double[assetSwap.indexDates.Count];

            for (var i = 0; i < assetSwap.indexDates.Count; i++)
            {
                indexValues[i] = forecastCurve.GetForwardRate(assetSwap.indexDates[i]);
            }
            assetSwap.SetIndexValues(assetSwap.index, indexValues);

            return(assetSwap);
        }