Exemple #1
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);
        }
Exemple #2
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);
        }