예제 #1
0
        public PricingResults PriceResults(IOption option, Dictionary <string, decimal> priceMarket, DateTime dateDebut, IDataFeedProvider dataFeedProvider)
        {
            Pricer pricer = new Pricer();
            int    length = priceMarket.Count;

            double[] spot = new double[length];
            for (int i = 0; i < spot.Length; i++)
            {
                spot[i] = (double)priceMarket.ElementAt(i).Value;
            }
            if (option is VanillaCall)
            {
                VanillaCall    optionVanilla = (VanillaCall)option;
                PricingResults priceDelta    = pricer.PriceCall(optionVanilla, dateDebut, dataFeedProvider.NumberOfDaysPerYear, spot[0], volatilite);
                return(priceDelta);
            }
            else
            {
                BasketOption optionBasket = (BasketOption)option;
                double[]     volatilities = new double[optionBasket.Weights.Length];
                for (int i = 0; i < optionBasket.Weights.Length; i++)
                {
                    volatilities[i] = volatilite;
                }
                PricingResults priceDelta = pricer.PriceBasket(optionBasket, dateDebut, dataFeedProvider.NumberOfDaysPerYear, spot, volatilities, matrixCorrelation);
                return(priceDelta);
            }
        }
 public InitializerViewModel()
 {
     debutTest            = DateTime.Now;
     maturity             = new DateTime(2019, 6, 7);
     plageEstimation      = 15;
     typeData             = new SimulatedDataFeedProvider();
     strike               = 8;
     periodeRebalancement = 5;
     nameOption           = "Vanilla Call";
     option               = new VanillaCall(nameOption, new Share("AIRBUS GROUP SE", "AIR FP    "), maturity, strike);
 }
예제 #3
0
        private void StartTicker()
        {
            List <Share> selectedShares = new List <Share>();

            foreach (var comp in AvailableShares)
            {
                if (comp.IsSelected)
                {
                    selectedShares.Add(new Share(comp.Name, comp.Id));
                }
            }
            int length = selectedShares.Count;

            Share[] sharesTab = new Share[length];
            for (int i = 0; i < sharesTab.Length; i++)
            {
                sharesTab[i] = selectedShares[i];
            }

            if ((selectedOptions == "vanillaCall" || UniverseVM.Initializer.Option is VanillaCall) && length == 1)
            {
                VanillaCall vanillaCall = new VanillaCall(UniverseVM.Initializer.NameOption, sharesTab[0], UniverseVM.Initializer.Maturity, UniverseVM.Initializer.Strike);
                universeVM.Simulation = new SimulationModel(vanillaCall, universeVM.Initializer.TypeData, UniverseVM.Initializer.DebutTest, UniverseVM.Initializer.PlageEstimation, UniverseVM.Initializer.PeriodeRebalancement);
            }
            else if (selectedOptions == "basketOption" && length > 1)
            {
                Random   aleatoire = new Random();
                double[] weights   = new double[length];

                for (int i = 0; i < length; i++)
                {
                    weights[i] = (double)1 / length;
                }
                BasketOption basketOption = new BasketOption(UniverseVM.Initializer.NameOption, sharesTab, weights, UniverseVM.Initializer.Maturity, UniverseVM.Initializer.Strike);
                universeVM.Simulation = new SimulationModel(basketOption, universeVM.Initializer.TypeData, UniverseVM.Initializer.DebutTest, UniverseVM.Initializer.PlageEstimation, UniverseVM.Initializer.PeriodeRebalancement);
            }
            else
            {
                MessageBox.Show("Vanilla Call supports only one share, and basket options supports at least two shares, previous option was taken");
            }
            universeVM.UnderlyingUniverse = new Universe(universeVM.Simulation, universeVM.GraphVM.Graph);
            if (win != null)
            {
                win.Close();
            }
            graphTest = universeVM.UnderlyingUniverse.Graph;
            win       = new GraphVisualization();
            win.Show();
            TickerStarted = false;
        }
예제 #4
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);
        }
예제 #5
0
        public IOption constructOption()
        {
            IOption option = null;

            if ((userInput.Weights == null) || userInput.Weights.Sum() != 1)
            {
                throw new ArgumentException("The sum of the weights must equal 1");
            }
            if (DateTime.Compare(userInput.StartDate, userInput.Maturity) >= 0)
            {
                throw new ArgumentException("The start date must be shorter than maturity");
            }
            List <Share> underlyingsShares = new List <Share>();

            foreach (string underlyingId in userInput.UnderlyingsIds)
            {
                String underlyingName = ShareTools.GetShareName(underlyingId);
                underlyingsShares.Add(new Share(underlyingName, underlyingId));
            }
            if (userInput.OptionType.Equals("VanillaCall"))
            {
                if (underlyingsShares.Count > 1)
                {
                    throw new ArgumentException("You have to choose only one underlying share for the Vanilla call");
                }
                option = new VanillaCall(userInput.NameOption, underlyingsShares[0], userInput.Maturity, userInput.Strike);
            }
            else if (userInput.OptionType.Equals("BasketOption"))
            {
                if (userInput.Weights.Length == 1)
                {
                    throw new ArgumentException("You have to choose multiple underlying shares for the Basket option");
                }
                option = new BasketOption(userInput.NameOption, underlyingsShares.ToArray(), userInput.Weights, userInput.Maturity, userInput.Strike);
            }
            else
            {
                throw new ArgumentException("Unkown OptionType " + userInput.OptionType);
            }

            return(option);
        }
예제 #6
0
        public Balancement(DataFeed data)
        {
            DateTime    dateDebut = DateTime.Now;
            VanillaCall option    = new VanillaCall("Vanilla Call", new Share("VanillaShare", "1"), new DateTime(2019, 12, 04), 8);
            var         priceList = dataFeedProvider.GetDataFeed(option, dateDebut);

            //Je pense en fait que la fonction Pricer c'est la fonction doit être un fonction qui renvoit pricedelta et du
            //coup c'est la bas qu'on differencie les baskets des vanilles
            pricer = new Pricer();
            PricingResults priceDelta         = pricer.PriceCall(option, dateDebut, dataFeedProvider.NumberOfDaysPerYear, Convert.ToDouble(priceList[0].PriceList[option.UnderlyingShareIds[1]]), 0.25);
            Dictionary <string, double> compo = new Dictionary <string, double> {
            };
            int i = 1;

            foreach (string id in option.UnderlyingShareIds)
            {
                compo[id] = priceDelta.Deltas[i];
                i        += 1;
            }
            // Le premier argument de portefeuille doit être le prix de l'option en 0;
            //Le deuxième la compo
            //le troisième le prix des actifs en 0
            List <decimal> priceOption = new List <decimal> {
                Convert.ToDecimal(priceDelta.Price)
            };
            Portfolio portfolio = new Portfolio(priceOption, compo, priceList[0].PriceList);

            //Traitement des données

            foreach (DataFeed priceAsset_t in priceList.Skip(1))
            {
                priceDelta = pricer.PriceCall(option, dateDebut, dataFeedProvider.NumberOfDaysPerYear, Convert.ToDouble(priceAsset_t.PriceList[option.UnderlyingShareIds[1]]), 0.25);
                //updateCompo
                foreach (string id in option.UnderlyingShareIds)
                {
                    compo[id] = priceDelta.Deltas[i];
                    i        += 1;
                }
                portfolio.UpdatePortfolioValue(priceAsset_t, dataFeedProvider.NumberOfDaysPerYear, periodeRebalancement);
                portfolio.UpdateCompo(compo);
            }
        }
예제 #7
0
        public void getDataSimul()
        {
            Console.WriteLine("debut de la generation de data");

            var               dataFeedCalc = new List <DataFeed>();
            DateTime          dateDebut    = new DateTime(2010, 1, 1);
            DateTime          dateFin      = new DateTime(2009, 1, 1);
            Share             action1      = new Share("accordId", "accordId");
            VanillaCall       vanille1     = new VanillaCall("accordId", action1, dateDebut, 10);
            IDataFeedProvider data         = new SimulatedDataFeedProvider();

            dataFeedCalc = data.GetDataFeed(vanille1, dateFin);
            Console.WriteLine(dataFeedCalc[0].Date);
            Console.WriteLine(dataFeedCalc[0].PriceList.ToString());
            decimal a = 10;

            dataFeedCalc[50].PriceList.TryGetValue("accordId", out a);
            Console.WriteLine(a);
            Console.WriteLine("fin");
        }
        private void StartTicker()
        {
            //universeVM = new UniverseViewModel();

            BasketOption basketOption = new BasketOption("Basket", new Share[] { new Share("CREDIT AGRICOLE SA", "ACA FP    "), new Share("AIR LIQUIDE SA", "AI FP     "), new Share("AIRBUS GROUP SE", "AIR FP    ") }, new double[] { 0.2, 0.2, 0.5, 0.1 }, UniverseVM.Initializer.Maturity, UniverseVM.Initializer.Strike);
            VanillaCall  vanillaCall  = new VanillaCall("Vanilla Call", new Share("AIRBUS GROUP SE", "AIR FP    "), UniverseVM.Initializer.Maturity, UniverseVM.Initializer.Strike);

            universeVM.Simulation = new SimulationModel(basketOption, new HistoricalDataFeedProvider(), UniverseVM.Initializer.DebutTest,
                                                        UniverseVM.Initializer.PlageEstimation);

            universeVM.UnderlyingUniverse = new Universe(universeVM.Simulation, universeVM.GraphVM.Graph);
            if (win != null)
            {
                win.Close();
            }
            graphTest = universeVM.UnderlyingUniverse.Graph;
            win       = new GraphVisualization();
            win.Show();
            TickerStarted = false;
        }
예제 #9
0
        public List <FinancialComputation> InitAvailableOptions(string filename)
        {
            var res = new List <FinancialComputation>();

            var sousJacentVanilla0 = new Share("AC", "AC FP     ");
            var maturityVanilla0   = new DateTime(2014, 9, 25);
            var vanilla0           = new VanillaCall("simu vanilla AC", sousJacentVanilla0, maturityVanilla0, 25);

            res.Add(new VanillaComputation(vanilla0));

            var sousJacentVanilla1 = new Share("AC", "AC FP     ");
            var maturityVanilla1   = new DateTime(2011, 9, 25);
            var vanilla1           = new VanillaCall("vanilla AC", sousJacentVanilla1, maturityVanilla1, 25);

            res.Add(new VanillaComputation(vanilla1));

            var sousJacentVanilla2 = new Share("BN", "BN FP     ");
            var maturityVanilla2   = new DateTime(2011, 9, 6);
            var vanilla2           = new VanillaCall("vanilla BN", sousJacentVanilla2, maturityVanilla2, 45);

            res.Add(new VanillaComputation(vanilla2));

            var sousJacentVanilla3 = new Share("CAP", "CAP FP    ");
            var maturityVanilla3   = new DateTime(2011, 9, 6);
            var vanilla3           = new VanillaCall("vanilla CAP", sousJacentVanilla3, maturityVanilla3, 35);

            res.Add(new VanillaComputation(vanilla3));

            var sousJacentBasket1 = new Share("AC", "AI FP     ");
            var sousJacentBasket2 = new Share("ACA", "CAP FP    ");
            var sousJacentBasket3 = new Share("EDF", "BN FP     ");
            var maturityBasket    = new DateTime(2013, 6, 11);
            var basket            = new BasketOption("basket AI CAP BN", new Share[] { sousJacentBasket1, sousJacentBasket2, sousJacentBasket3 }, new double[] { 0.3, 0.3, 0.4 }, maturityBasket, 9);

            res.Add(new BasketComputation(basket));

            return(res);
        }
예제 #10
0
        /*
         * Method to calculate all the pricings in between a certain date and the maturity.
         *
         * */
        public List <PricingResults> pricingUntilMaturity(List <DataFeed> listDataFeed)
        {
            if (oName.Equals(null) || oShares.Equals(null) || oMaturity == null || oStrike.Equals(null) || listDataFeed.Count == 0)
            {
                throw new NullReferenceException();
            }
            List <PricingResults> listPrix = new List <PricingResults>();
            List <DataFeed>       listdf   = new List <DataFeed>(listDataFeed);


            VanillaCall vanny = new VanillaCall(oName, oShares, oMaturity, oStrike);

            while (listdf.Count > oObservation)
            {
                calculVolatility(listdf);
                double listPrice = (double)listdf[oObservation].PriceList[oShares[0].Id];
                oSpot[0] = listPrice;
                listPrix.Add(vanillaPricer.PriceCall(vanny, listdf[oObservation].Date, businessDays, oSpot[0], oVolatility[0]));
                vanillaPricer.PriceCall(vanny, listdf[oObservation].Date, businessDays, oSpot[0], oVolatility[0]);
                listdf.RemoveAt(0);
            }

            return(listPrix);
        }
예제 #11
0
        public static void Main(string[] args)
        {
            Share share1 = new Share("vodName", "vod.l");
            Share share2 = new Share("ftse", "ftse");

            string[] shareNames = new string[2] {
                "vodName", "ftseName"
            };
            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);
            BasketOption optionBasket2  = new BasketOption("BASKETTT", sharesBasket, weights, maturityBasket, strikeBasket);

            VanillaCall optionVanille  = new VanillaCall("Vanille", sharesBasket[0], maturityBasket, strikeBasket);
            VanillaCall optionVanille2 = new VanillaCall("Vanille2", sharesBasket[0], maturityBasket, strikeBasket);



            JsonHandler jsonHandle = new JsonHandler();

            jsonHandle.SaveOption(optionVanille);
            jsonHandle.SaveOption(optionVanille);
            jsonHandle.SaveOption(optionVanille2);
            jsonHandle.SaveOption(optionBasket);
            jsonHandle.SaveOption(optionBasket2);
            jsonHandle.SaveOption(optionBasket);

            jsonHandle.SaveOption(optionBasket);
            jsonHandle.LoadOptions();
            List <VanillaCall>  listOptions = jsonHandle.ListVanillaCalls;
            List <BasketOption> listBasket  = jsonHandle.ListBasketOptions;
        }
예제 #12
0
        // Action déclenché à l'appui sur le bouton start
        private void StartTicker()
        {
            // Déclaration des paramètres
            DateTime maturity = new DateTime(2014, 12, 20);
            DateTime initialDate = new DateTime(2013, 1, 20);
            DateTime estimationDate = new DateTime();
            int windowLength = 10;
            int numberOfDaysPerYear = 0;
            double strike = 0;
            List<Share> shareList = new List<Share>();
            List<DataFeed> dataFeedList = new List<DataFeed>();

            if (SelectedOption == "Vanilla Call")
            {
                if (Simulated)
                {
                    // ----------- Vanilla Call donnees simulees --------

                    // Parametrage
                    strike = 8;
                    estimationDate = Utilities.getEstimationDateForSimulatedData(initialDate, windowLength);
                    shareList.Add(new Share("BNP PARIBAS", "BNP FP"));

                    // Creation de l'option
                    Option option = new VanillaCall("Vanilla Call", shareList.ToArray(), maturity, strike);

                    // Récupération des donnes simulées
                    IDataFeedProvider data = new SimulatedDataFeedProvider();
                    dataFeedList = data.GetDataFeed(option, estimationDate);
                    numberOfDaysPerYear = data.NumberOfDaysPerYear;

                    // Fournisseur de composition du portefeuille de réplication
                    CompositionProvider compositionProvider = new VanillaCompositionProvider(option);

                    // Main partagé
                    sharedMain(option, compositionProvider, dataFeedList, shareList, initialDate, strike, maturity, windowLength, numberOfDaysPerYear, Simulated);
                }
                else
                {
                    // ----------- Vanilla Call donnees historiques --------
                    strike = 35;
                    estimationDate = Utilities.getEstimationDateForHistoricalData(initialDate, windowLength);
                    shareList.Add(new Share("BNP PARIBAS", "BNP FP"));

                    Option option = new VanillaCall("Vanilla Call", shareList.ToArray(), maturity, strike);

                    IDataFeedProvider data = new HistoricalDataFeedProvider("historicalData", 365);
                    dataFeedList = data.GetDataFeed(option, estimationDate);
                    numberOfDaysPerYear = data.NumberOfDaysPerYear;

                    CompositionProvider compositionProvider = new VanillaCompositionProvider(option);

                    sharedMain(option, compositionProvider, dataFeedList, shareList, initialDate, strike, maturity, windowLength, numberOfDaysPerYear, Simulated);
                }
            }
            else if (SelectedOption == "Basket Option")
            {
                if (Simulated)
                {
                    // ----------- Basket option donnees simulees --------
                    strike = 8;
                    estimationDate = Utilities.getEstimationDateForSimulatedData(initialDate, windowLength);
                    shareList.Add(new Share("BNP PARIBAS", "BNP FP"));
                    shareList.Add(new Share("ACCOR SA", "ALO FP"));
                    double[] weights = { 0.3, 0.7 };

                    Option option = new BasketOption("Basket option", shareList.ToArray(), weights, maturity, strike);

                    IDataFeedProvider data = new SimulatedDataFeedProvider();
                    dataFeedList = data.GetDataFeed(option, estimationDate);
                    numberOfDaysPerYear = data.NumberOfDaysPerYear;

                    CompositionProvider compositionProvider = new BasketCompositionProvider(option);

                    sharedMain(option, compositionProvider, dataFeedList, shareList, initialDate, strike, maturity, windowLength, numberOfDaysPerYear, Simulated);
                }
                else
                {
                    // ----------- Basket option donnees historiques --------
                    strike = 35;
                    estimationDate = Utilities.getEstimationDateForHistoricalData(initialDate, windowLength);
                    shareList.Add(new Share("BNP PARIBAS", "BNP FP"));
                    shareList.Add(new Share("ACCOR SA", "ALO FP"));
                    double[] weights = { 0.3, 0.7 };

                    Option option = new BasketOption("Basket option", shareList.ToArray(), weights, maturity, strike);

                    IDataFeedProvider data = new HistoricalDataFeedProvider("historicalData", 365);
                    dataFeedList = data.GetDataFeed(option, estimationDate);
                    numberOfDaysPerYear = data.NumberOfDaysPerYear;

                    CompositionProvider compositionProvider = new BasketCompositionProvider(option);

                    sharedMain(option, compositionProvider, dataFeedList, shareList, initialDate, strike, maturity, windowLength, numberOfDaysPerYear, Simulated);
                }
            }
        }
예제 #13
0
        public static double UpdatePortfolio(DateTime maturity, double risklessRate, DateTime date, SimulatedDataFeedProvider data, VanillaCall call, int nbDaysPerYear,
                                             double volatility)
        {
            List <DataFeed> spotList = data.GetDataFeed(call, date); //
            decimal         spot     = spotList[0].PriceList[call.UnderlyingShare.Id];

            PricingResults price;

            price = Pricer.PriceCall(call, date, nbDaysPerYear, (double)spot, volatility); //
            double pricePortfolio = price.Price;
            double delta          = price.Deltas[0];
            double riskyPosition  = delta;
            //Dictionary<string, decimal> price = datafeed.PriceList.TryGetValue(call.Name,out 0);
            double riskFreePosition = pricePortfolio - delta * (double)spot;

            while (date < maturity)
            {
                date.AddDays(1);
                spotList         = data.GetDataFeed(call, date); //
                spot             = spotList[0].PriceList[call.UnderlyingShare.Id];
                pricePortfolio   = riskyPosition * (double)spot + riskFreePosition * Math.Exp(risklessRate / 365);
                price            = Pricer.PriceCall(call, date, nbDaysPerYear, (double)spot, volatility); //
                delta            = price.Deltas[0];
                riskyPosition    = delta;
                riskFreePosition = pricePortfolio - delta * (double)spot;
            }
            return(riskyPosition * (double)spot + riskFreePosition * Math.Exp(risklessRate / 365));
        }
예제 #14
0
        public PricingResults ComputeDeltaCall(VanillaCall call, DateTime atTime, int nbDaysPerYear, double spot, double volatility)
        {
            PricingResults price = new PriceCall(call, atTime, nbDaysPerYear, spot, volatility);

            return(price);
        }
예제 #15
0
 public VanillaCallPricer(VanillaCall opt) : base(opt)
 {
 }
예제 #16
0
        public static void Main(string[] args)
        {
            int      strike     = 9;
            double   volatility = 0.4;
            DateTime maturity   = new DateTime(2019, 09, 04);
            DateTime beginDate  = new DateTime(2018, 09, 04);
            int      totalDays  = DayCount.CountBusinessDays(beginDate, maturity);

            Share[] share = { new Share("Sfr", "1254798") };
            if (share.Length == 1)
            {
                VanillaCall callOption = new VanillaCall("Vanille", share[0], maturity, strike);

                /* Simulated data feeds : */
                SimulatedDataFeedProvider simulator = new SimulatedDataFeedProvider();
                List <DataFeed>           dataFeeds = simulator.GetDataFeed(callOption, beginDate);
                int numberOfDaysPerYear             = simulator.NumberOfDaysPerYear;

                /* Portfolio initialisation : */
                Portfolio portfolio = new Portfolio();
                portfolio.PortfolioComposition = new Dictionary <String, double>();

                Pricer pricer = new Pricer();



                double         spot           = (double)dataFeeds[0].PriceList[share[0].Id];
                PricingResults pricingResults = pricer.PriceCall(callOption, beginDate, totalDays, spot, volatility);
                double         callPrice      = pricingResults.Price;
                portfolio.FirstPortfolioValue   = callPrice;
                portfolio.CurrentPortfolioValue = callPrice;
                portfolio.CurrentDate           = beginDate;
                double previousDelta = pricingResults.Deltas[0];

                portfolio.PortfolioComposition.Add(share[0].Id, previousDelta);

                double   payoff         = 0;
                double[] optionValue    = new Double[totalDays];
                double[] portfolioValue = new Double[totalDays];
                optionValue[0]    = callPrice;
                portfolioValue[0] = portfolio.CurrentPortfolioValue;

                int indexArrays = 1;
                /* Skip the first day : because it's already initialized*/
                foreach (DataFeed data in dataFeeds.Skip(1))
                {
                    if (data != dataFeeds.Last())
                    {
                        portfolio.updateValue(spot, data, pricer, callOption, volatility, numberOfDaysPerYear);
                        spot = updateSpot(data, share[0]);

                        double pricing = getPricingResult(data, callOption, pricer, volatility, numberOfDaysPerYear);

                        /* Fill arrays of optionValue and portfolioValue */

                        optionValue[indexArrays]    = pricing;
                        portfolioValue[indexArrays] = portfolio.CurrentPortfolioValue;

                        Console.WriteLine("Valeur option = " + optionValue[indexArrays]);
                        Console.WriteLine("Valeur portefeuille = " + portfolioValue[indexArrays]);
                    }

                    /* For the last day : */
                    else
                    {
                        portfolio.CurrentDate = data.Date;
                        payoff = callOption.GetPayoff(data.PriceList);
                    }
                    indexArrays++;
                }

                /* Partie traçage de courbes */
                using (System.IO.StreamWriter file =
                           new System.IO.StreamWriter(@"C:\Users\ensimag\Desktop\WriteLines.txt"))
                {
                    for (int index = 0; index < totalDays; index++)
                    {
                        // If the line doesn't contain the word 'Second', write the line to the file.
                        file.WriteLine(optionValue[index]);
                        file.WriteLine(portfolioValue[index]);
                    }
                }


                //double valuePortfolio = (portfolio.currentPortfolioValue - payoff) / portfolio.firstPortfolioValue;
                //Console.WriteLine("Valeur = " + valuePortfolio);

                Portfolio portefolioTest      = new Portfolio();
                double    finalportfolioValue = portfolio.updatePortfolio(pricer, callOption, dataFeeds, numberOfDaysPerYear, share[0], totalDays, volatility, beginDate);

                Console.WriteLine("Valeur = " + finalportfolioValue);
            }
        }
예제 #17
0
 public VanillaComputation(VanillaCall v) : base(v)
 {
     Vanilla = v;
 }