Ejemplo n.º 1
0
        /*** Test for data simulation ***/
        /* Print all loaded values 
         * for one share between two dates */
        public void TestLoadedDataBasket()
        {
            DateTime date = DateTime.Now;
            PricingLibrary.FinancialProducts.Share Action1 = new PricingLibrary.FinancialProducts.Share("JJ", "ALO FP");
            PricingLibrary.FinancialProducts.Share Action2 = new PricingLibrary.FinancialProducts.Share("JJ", "BNP FP");

            PricingLibrary.FinancialProducts.Share[] tabAction = { Action1, Action2};
            double[] poids = new double[2] {0.4, 0.6};
            PricingLibrary.FinancialProducts.BasketOption Call = new PricingLibrary.FinancialProducts.BasketOption("JJ", tabAction, poids, date, 30.0);

            DateTime date1 = new DateTime(2015, 6, 1, 0, 0, 0);

            ShareHisto myShareHisto = new ShareHisto(date1, date, Call);

            myShareHisto.loadingSQL();

            foreach (PricingLibrary.Utilities.MarketDataFeed.DataFeed d in myShareHisto.Data)
            {
                foreach (KeyValuePair<string, decimal> t in d.PriceList)
                {
                    Console.WriteLine("Date : " + d.Date);
                    Console.WriteLine("" + t.Key + "   " + t.Value);
                }
            }

        }
Ejemplo n.º 2
0
        public void TestVolatilitiesAndSpotPrices()
        {
            DateTime date = new DateTime(2014, 6, 1, 0, 0, 0);
            DateTime date1 = new DateTime(2014, 1, 1, 0, 0, 0);
            PricingLibrary.FinancialProducts.Share Action = new PricingLibrary.FinancialProducts.Share("test", "ALO FP");
            PricingLibrary.FinancialProducts.Share Action2 = new PricingLibrary.FinancialProducts.Share("test2", "BNP FP");
            PricingLibrary.FinancialProducts.Share[] mesActions = new PricingLibrary.FinancialProducts.Share[2];
            mesActions[0] = Action;
            mesActions[1] = Action2;
            double[] weight = { 0.1, 0.9 };
            PricingLibrary.FinancialProducts.BasketOption myBasketOption = new PricingLibrary.FinancialProducts.BasketOption("test", mesActions, weight, date, 30.0);
            OptionManager myOptionManager = new OptionManager(myBasketOption, date1, date, 20, false); 

            Console.WriteLine(" Premiers resultats : ");
            myOptionManager.HedgingPortfolioValue.ForEach(data => Console.WriteLine(data));
            Console.WriteLine(" \n ");
            myOptionManager.Payoff.ForEach(data => Console.WriteLine(data));
            Console.WriteLine(" \n ");


           ComputeResults.computeResults(myOptionManager);

            Console.WriteLine(" Fin : \n");
            Console.WriteLine("\n");
            myOptionManager.HedgingPortfolioValue.ForEach(data => Console.WriteLine(data));
            Console.WriteLine("\n");
            //myResults.OptionPrice.ForEach(data => Console.WriteLine(data));
            Console.WriteLine(" Option price \n");
            myOptionManager.OptionPrice.ForEach(data => Console.WriteLine(data));
            Console.WriteLine(" \n ");
            Console.WriteLine(" \n ");
            myOptionManager.dateTime.ForEach(data => Console.WriteLine(data));
        }
Ejemplo n.º 3
0
        private void ExtractComponents()
        {
            // On test les différents paramètres, si ils ne sont pas bons on fait apparaitre un pop-up
            double sommePoids = 0.0;
            int nbAction = 0;
            foreach (var comp in ComponentInfoList)
            {
                if (comp.IsSelected)
                {
                    if (comp.Poids < 0.0)
                    {
                        System.Windows.Forms.MessageBox.Show("ERREUR : Les poids doivent être positif");
                        return;
                    }
                    sommePoids += comp.Poids;
                    nbAction += 1;
                }
            }
            if (sommePoids != 1.0)
            {
                System.Windows.Forms.MessageBox.Show("ERREUR : La somme des poids doit être égale à 1 ");
                return;
            }

            PricingLibrary.FinancialProducts.Share[] tabShare = new PricingLibrary.FinancialProducts.Share[nbAction];
            double[] tabWeight = new double[nbAction];

            if (tailleFenetre < 0)
            {
                System.Windows.Forms.MessageBox.Show("ERREUR : La taille de la fenetre doit être superieure à 0 ");
                return;
            }

            if (maturite.Subtract(dateDebut).Days < tailleFenetre)
            {
                System.Windows.Forms.MessageBox.Show("ERREUR : La taille de la fenetre ne doit pas être plus grande que l'écart entre la maturite et la date de début ");
                return;
            }

            if (tailleFenetre < nbAction)
            {
                System.Windows.Forms.MessageBox.Show("ERREUR : La taille de la fenetre doit être un entier au minimum égale au nombre de sous jacent ");
                return;
            }
            if ((1 < nbAction)&&(typeOption.Equals("Vanilla Call")))
            {
                System.Windows.Forms.MessageBox.Show("ERREUR : Un Vanilla Call ne peut avoir qu'un sous-jacent ");
                return;
            }


            // On utilise maintenant nb action comme index
            nbAction = 0;
            foreach (var comp in ComponentInfoList)
            {
                if (comp.IsSelected)
                {
                    PricingLibrary.FinancialProducts.Share share = new PricingLibrary.FinancialProducts.Share(comp.Name, comp.Name);
                    tabShare[nbAction] = share;
                    tabWeight[nbAction] = comp.Poids;
                    nbAction += 1;
                }
            }



            if (strikePrice < 0)
            {
                System.Windows.Forms.MessageBox.Show("ERREUR : Le strike doit être positif");
                return;
            }

            TimeSpan diff = maturite.Subtract(dateDebut);
            if (diff.Days < 0)
            {
                System.Windows.Forms.MessageBox.Show("ERREUR : La date de debut doit etre avant la maturite ");
                return;
            }


            if (!typeDonnees.Equals("Simulées") && !typeDonnees.Equals("Historiques"))
            {
                System.Windows.Forms.MessageBox.Show("ERREUR Type de données : Choisir l'une des deux possibilités ");
                return;
            }
            bool simule;
            if (typeDonnees.Equals("Simulées")) {
                simule = true;
            } else {
                simule = false;
            }

            PricingLibrary.FinancialProducts.IOption option;
            if (typeOption.Equals("Vanilla Call"))
            {
                option = new PricingLibrary.FinancialProducts.VanillaCall("call", tabShare, maturite, strikePrice);
            }
            else
            {
                option = new PricingLibrary.FinancialProducts.BasketOption("basket", tabShare, tabWeight, maturite, strikePrice);
            }

            ////////////////////////////////////////////////////////////////////////////

            // On calcule le portefeuilles de couverture de l'option
            OptionManager optionCompute = new OptionManager(option,dateDebut,maturite,tailleFenetre,simule);
            ComputeResults.computeResults(optionCompute);

            // On trace les graphes
            LineSeries courbe = tabToSeries(optionCompute.OptionPrice, optionCompute.dateTime);
            LineSeries courbe2 = tabToSeries(optionCompute.HedgingPortfolioValue, optionCompute.dateTime);

            this.MyModel.Series.Clear();
            this.MyModel.Axes.Clear();

            double min = Math.Min(optionCompute.OptionPrice.Min(),optionCompute.HedgingPortfolioValue.Min())-0.1;
            double max = Math.Max(optionCompute.OptionPrice.Max(), optionCompute.HedgingPortfolioValue.Max())+0.1;
            SetUpModel(min, max, optionCompute.dateTime.Min());

            courbe.Title = "Prix de l'option";
            courbe2.Title = "Valeur Portefeuille de Couverture";
            this.MyModel.Series.Add(courbe);
            this.MyModel.Series.Add(courbe2);

            // On met à jour les graphes
            this.MyModel.InvalidatePlot(true);
            this.MyModel.PlotView.InvalidatePlot(true);

        }
Ejemplo n.º 4
0
        public void RebalancementBasket1SJ_S8()
        {
            double ratio = 0;
            double compteur = 0;

            for (int i = 0; i < 200; i++)
            {
                DateTime date = DateTime.Now;
                PricingLibrary.FinancialProducts.Share Action = new PricingLibrary.FinancialProducts.Share("ALO FP", "ALO FP");

                
                PricingLibrary.FinancialProducts.Share[] tabAction = { Action };
                double[] weightTab = new double[] {1.0};

                PricingLibrary.FinancialProducts.BasketOption Basket = new PricingLibrary.FinancialProducts.BasketOption("BASKET", tabAction, weightTab, date, 9.0);

                DateTime dateStart = new DateTime(2014, 10, 9, 0, 0, 0);

                OptionManager optionCompute = new OptionManager(Basket, dateStart, date, 30, true);
                ComputeResults.computeResults(optionCompute);



                double firstValue = optionCompute.HedgingPortfolioValue[0];
                double lastValue = optionCompute.HedgingPortfolioValue[optionCompute.HedgingPortfolioValue.Count - 1];
                double payoff = optionCompute.Payoff[optionCompute.Payoff.Count - 1];

                double ratioTmp = Math.Abs(payoff - lastValue) / firstValue;

                
                ratio += ratioTmp;
                compteur += 1;
            }

            ratio = ratio / compteur;
            Console.WriteLine(ratio);

        }
Ejemplo n.º 5
0
        public void RebalancementBasket5Sj()
        {
            double ratio = 0;
            double compteur = 0;

            for (int i = 0; i < 200; i++)
            {
                DateTime date = DateTime.Now;
                PricingLibrary.FinancialProducts.Share Action = new PricingLibrary.FinancialProducts.Share("test", "01");

                PricingLibrary.FinancialProducts.Share Action1 = new PricingLibrary.FinancialProducts.Share("test1", "02");

                PricingLibrary.FinancialProducts.Share Action2 = new PricingLibrary.FinancialProducts.Share("test1", "03");

                PricingLibrary.FinancialProducts.Share Action3 = new PricingLibrary.FinancialProducts.Share("test1", "04");

                PricingLibrary.FinancialProducts.Share Action4 = new PricingLibrary.FinancialProducts.Share("test1", "05");

                PricingLibrary.FinancialProducts.Share[] tabAction = { Action, Action1, Action2, Action3,Action4 };
                double[] weightTab = new double[] {0.2,0.2,0.2,0.2,0.2};

                PricingLibrary.FinancialProducts.BasketOption Basket = new PricingLibrary.FinancialProducts.BasketOption("basket", tabAction, weightTab, date, 8);


                DateTime dateStart = new DateTime(2015, 2, 10, 0, 0, 0);
                OptionManager optionCompute = new OptionManager(Basket, dateStart, date, 30, true);
                ComputeResults.computeResults(optionCompute);



                double firstValue = optionCompute.HedgingPortfolioValue[0];
                double lastValue = optionCompute.HedgingPortfolioValue[optionCompute.HedgingPortfolioValue.Count - 1];
                double payoff = optionCompute.Payoff[optionCompute.Payoff.Count - 1];

                double ratioTmp = Math.Abs(payoff - lastValue) / firstValue;

                ratio += ratioTmp;
                compteur += 1;
            }

            ratio = ratio / compteur;
            Console.WriteLine(ratio);
        }