public static void Main(string[] args)
        {
            var      simulatedData = new SimulatedDataProvider();
            DateTime from          = new DateTime(2018, 09, 04);
            Share    share1        = new Share("vod.l", "vod.l");
            Share    share2        = new Share("ftse", "ftse");
            string   nameBasket    = "Basket";
            double   strikeBasket  = 9;

            Share[]         sharesBasket    = { share1, share2 };
            Double[]        weights         = { 0.3, 0.7 };
            DateTime        maturityBasket  = new DateTime(2019, 09, 04);
            BasketOption    optionBasket    = new BasketOption(nameBasket, sharesBasket, weights, maturityBasket, strikeBasket);
            PortfolioBasket portfolioBasket = new PortfolioBasket();
            int             totalDays       = DayCount.CountBusinessDays(from, maturityBasket);

            double[] volatility = new double[2];
            volatility[0] = 0.4;
            volatility[1] = 0.4;
            double[,] correlationMatrix = new double[2, 2];
            correlationMatrix[0, 0]     = 1;
            correlationMatrix[1, 1]     = 0.1;
            correlationMatrix[0, 1]     = 1;
            correlationMatrix[1, 0]     = 0.1;
            double valeur = portfolioBasket.PortfolioValue(optionBasket, sharesBasket, totalDays, volatility, correlationMatrix, from);

            Console.WriteLine("Valeur Gain normalisée = " + valeur);
        }
Beispiel #2
0
        public static void Main(string[] args)
        {
            // header

            var      simulatedData = new SimulatedDataProvider();
            DateTime from          = new DateTime(2018, 09, 04);
            DateTime maturity      = new DateTime(2019, 09, 04);
            string   name          = "VanillaCall";
            double   strike        = 7000;
            Share    underlying    = new Share("vod.l", "vod.l");
            IOption  option        = new VanillaCall(name, underlying, maturity, strike);
            var      lst           = simulatedData.GetDataFeeds(option, from);

            Console.WriteLine("************************************");
            Console.WriteLine("*    Test Simulation CallVanille   *");
            Console.WriteLine("************************************");
            foreach (DataFeed element in lst)
            {
                Console.WriteLine("\n\n\n\n" + element.Date.ToString() + "\n" + string.Join(",", element.PriceList.Select(kv => kv.Key + "=" + kv.Value).ToArray()));
            }
            Console.WriteLine("**************End of simulation Vanille****************");

            Share  share1       = new Share("vod.l", "vod.l");
            Share  share2       = new Share("ftse", "ftse");
            string nameBasket   = "Basket";
            double strikeBasket = 7000;

            Share[]         sharesBasket     = { share1, share2 };
            Double[]        weights          = { 0.3, 0.7 };
            DateTime        maturityBasket   = new DateTime(2019, 09, 04);
            IOption         optionBasket     = new BasketOption(nameBasket, sharesBasket, weights, maturityBasket, strikeBasket);
            List <DataFeed> simulationBasket = simulatedData.GetDataFeeds(optionBasket, from);

            Console.WriteLine("\n\n\n\n");
            Console.WriteLine("************************************");
            Console.WriteLine("*    Test Simulation BasketOption   *");
            Console.WriteLine("************************************");
            foreach (DataFeed element in simulationBasket)
            {
                Console.WriteLine("\n\n\n\n" + element.Date.ToString() + "\n" + string.Join(",", element.PriceList.Select(kv => kv.Key + "=" + kv.Value).ToArray()));
            }
            Console.WriteLine("**************End of simulation BasketOption****************");
            String[] id = simulationBasket[0].PriceList.Keys.ToArray();
            Console.WriteLine("Basket ID : " + id[0] + " et " + id[1]);
            Console.WriteLine("Basket : " + simulationBasket[0].PriceList.Keys.ToString());
            Console.WriteLine("Vanille : " + lst[0].PriceList.Count);
            Console.WriteLine("Vanille dates : " + lst.Count);
            Console.ReadKey(true);
        }
        public static void Main(string[] args)
        {
            var      simulatedData = new SimulatedDataProvider();
            DateTime from          = new DateTime(2010, 01, 01);
            Share    share1        = new Share("vod.l", "vod.l");
            Share    share2        = new Share("ftse", "ftse");
            Share    share3        = new Share("sfr", "sfr");
            Share    share4        = new Share("sx5e", "sx5e");
            string   nameBasket    = "Basket";
            double   strikeBasket  = 7000;

            Share[]         sharesBasket     = { share1, share2, share3, share4 };
            Double[]        weights          = { 0.2, 0.5, 0.2, 0.1 };
            DateTime        maturityBasket   = new DateTime(2151, 01, 20);
            IOption         optionBasket     = new BasketOption(nameBasket, sharesBasket, weights, maturityBasket, strikeBasket);
            List <DataFeed> simulationBasket = simulatedData.GetDataFeeds(optionBasket, from);


            ParametersEstimation parameters = new ParametersEstimation(simulationBasket, new DateTime(2150, 01, 20), 15000);
            var correlationMatrix           = parameters.Correlation;
            int Size = correlationMatrix.GetLength(0);

            Console.WriteLine("\n \n \n La matrice de correlation est : \n ");
            for (int i = 0; i < Size; i++)
            {
                for (int j = 0; j < Size; j++)
                {
                    Console.Write(correlationMatrix[i, j] + new string(' ', 30 - correlationMatrix[i, j].ToString().Length));
                }
                Console.Write("\n");
            }

            var volatilityTable = parameters.Volatility;

            Console.WriteLine("\n \n \n la volatilite est : \n ");
            for (int i = 0; i < Size; i++)
            {
                Console.WriteLine(volatilityTable[i]);
            }
            Console.ReadKey(true);
        }