예제 #1
0
        private static double CalculateMarkToMarket(SwapModel swapModel, double notional, double fixedRate, int currentYear)
        {
            var yearSwap = swapModel.ForwardRates.Count - currentYear;


            throw new NotImplementedException();
        }
예제 #2
0
        private static double[] CalculateDiscountFactors(SwapModel swapModel)
        {
            var discountFactors = new double[swapModel.ZeroCouponRates.Count];

            foreach (var zeroCouponRate in swapModel.ZeroCouponRates)
            {
                discountFactors[zeroCouponRate.Key - 1] = 1 / Math.Pow(1 + zeroCouponRate.Value, zeroCouponRate.Key);
            }

            return(discountFactors);
        }
예제 #3
0
        private static double CalculateSwapRate(SwapModel swapModel, int year)
        {
            var swapRate           = 0.0;
            var discountFactors    = CalculateDiscountFactors(swapModel);
            var discountFactorsSum = SumDiscountFactors(discountFactors, year);

            for (int i = 0; i < year; i++)
            {
                var weight = (discountFactors[i] / discountFactorsSum);
                swapRate += weight * swapModel.ForwardRates[i + 1];
            }

            return(swapRate * 100);
        }
예제 #4
0
        static void Main(string[] args)
        {
            var swapCurve = DataLoader.LoadSwapCurve(SwapCurveTableNames.Table3_5);

            var zeroCouponRates = GetZeroCouponRates(swapCurve);

            PrintRates(zeroCouponRates, Rates.ZeroCouponRates);

            var forwards = GetForwardRates(zeroCouponRates);

            PrintRates(forwards, Rates.ForwardRates);

            var swapModel = new SwapModel(zeroCouponRates, forwards);

            var swapRate = CalculateSwapRate(swapModel, 3);

            Console.WriteLine(swapRate);

            //var NPV = CalculateMarkToMarket(swapModel, 100000000, 7.0, 3);
        }