Esempio n. 1
0
        public void TestGenHistOptionForward()
        {
            String      VanillaCallName = "FistOptionName";
            DataGestion dataConn        = new DataGestion();

            Share[] underlyingShares = new Share[dataConn.numberOfAssets()];

            var listeID = dataConn.getListofID();

            for (int i = 0; i < dataConn.numberOfAssets(); i++)
            {
                underlyingShares[i] = new Share(dataConn.getName(listeID.ToArray()[i]), listeID.ToArray()[i]);
            }
            DateTime endTime   = new DateTime(2016, 1, 1);
            DateTime startDate = new DateTime(2015, 10, 10);
            double   strike    = 100.0;

            double[] weight = new double[dataConn.numberOfAssets()];
            for (int i = 0; i < dataConn.numberOfAssets(); i++)
            {
                weight[i] = 1 / dataConn.numberOfAssets();
            }


            IGenerateHistory test = new ForwardTestGenerate();

            test.endTime          = endTime;          //
            test.strike           = strike;           //
            test.underlyingShares = underlyingShares; //
            test.vanillaCallName  = VanillaCallName;  //
            test.weight           = weight;           //
            test.startDate        = startDate;        //
            List <DataFeed> ret = test.generateHistory();

            Console.WriteLine("----");
            foreach (DataFeed dataf in ret)
            {
                List <string> keyList = new List <string> (ret.ToArray()[0].PriceList.Keys);

                foreach (var ele in keyList)
                {
                    Console.WriteLine(dataf.Date);
                    Console.WriteLine(dataf.PriceList[ele]);
                }
            }
        }
Esempio n. 2
0
        public void testVolatilityBasket()
        {
            ForwardTestGenerate f = new ForwardTestGenerate();

            f.vanillaCallName = "Basket NAME";
            Share[] under = new Share[4];

            under[0]           = new Share("1A", "ID1");
            under[1]           = new Share("2A", "ID2");
            under[2]           = new Share("3A", "ID3");
            under[3]           = new Share("4A", "ID4");
            f.underlyingShares = under;
            f.weight           = new double[4] {
                0.25, 0.25, 0.25, 0.25
            };
            f.endTime   = new DateTime(2014, 09, 09);
            f.startDate = new DateTime(2013, 12, 12);
            f.strike    = 20.0;
            List <DataFeed> datum = f.generateHistory();

            BasketPricingModel vcpm = new BasketPricingModel();

            vcpm.oWeights = f.weight;
            vcpm.oSpot    = new double[4] {
                10, 10, 10, 10
            };
            vcpm.currentDate = f.startDate;
            vcpm.oStrike     = 20.0;
            vcpm.oMaturity   = f.endTime;
            vcpm.oShares     = f.underlyingShares;
            vcpm.oName       = f.vanillaCallName;

            vcpm.calculVolatility(datum);
            //Console.WriteLine(vcpm.oVolatility);

            /*for (int i = 0; i < 4; i++)
             * {*/
            //System.Diagnostics.Debug.Assert(vcpm.oVolatility[i] > 0.3 && vcpm.oVolatility[i] < 0.5);
            Console.WriteLine(vcpm.oVolatility[0]);
            //}
        }