Exemplo n.º 1
0
        public RecupData DataCommon()
        {
            RecupData res = new RecupData(this.dateDebut, this.dateFin);

            res.Symbols = new List <String>(this.Symbols);
            return(null);
        }
Exemplo n.º 2
0
        static void Main()
        {
            Random    random         = new Random();
            double    prix           = 0;
            double    tracking_error = 0;
            DateTime  dateDebut      = new DateTime(2014, 12, 22);
            DateTime  dateFin        = DateTime.Today;
            DateTime  finProduit     = new DateTime(2022, 12, 08);
            RecupData data           = new RecupData(dateDebut, dateFin);

            data.Fetch();
            //data.exportPast(1,7,dateDebut,new DateTime(2022,12,22));
            //data.exportCov(new DateTime(2014, 12, 22), new DateTime(2015, 5, 22));
            //double[] euro = data.GetEurostralHisto(dateDebut, 28, DateTime.Today);
            //data.Restreindre(new DateTime(2005,01,01), new DateTime(2005, 12, 31));
            //double[,] cov = data.exportCov(new DateTime(2007, 01, 01), new DateTime(2007, 12, 31));
            //double[] vol = data.exportVol();
            //double[,] past = data.exportPast(2.5, 182, new DateTime(2014, 12, 18), DateTime.Today);
            Stock stock = new Stock(data);

            double[] deltas = new double[5];
            double   cash   = 0.0;
            int      taille = 365;

            for (int i = 0; i < taille; i++)
            {
                cash = random.NextDouble() * 100;
                for (int j = 0; j < 5; j++)
                {
                    deltas[j] = random.NextDouble() * 2 - 1;
                }
                if (i != 0)
                {
                    prix = prix + 2 * random.NextDouble() - 1;
                }
                else
                {
                    prix = 100 * random.NextDouble();
                }
                tracking_error = random.NextDouble() * 5 + 2.5;
                stock.Add(i * data.DateToDouble(dateDebut, DateTime.Today, finProduit) / taille, deltas, prix, tracking_error, cash);
            }
            stock.SaveToCSV();

            /*for (int i = 0; i<5; i++)
             * {*/
            //Console.WriteLine(stock.getDelta(0.00218798716185236)[0]);
            //}
            Stock stockRead = new Stock("histo.csv", data);

            Console.WriteLine("Fin du programme ...");
            Console.ReadLine();
        }
Exemplo n.º 3
0
        public Stock(string filePath, RecupData data)
        {
            if (!File.Exists(filePath))
            {
                throw new Exception("[ERREUR]Fichier passé en entré non trouvé !");
            }
            this.data = data;
            InitializeHeader();
            donnees = new Dictionary <double, List <double> >();
            List <string> AllDonnees = new List <string>();

            using (TextFieldParser parser = new TextFieldParser(filePath))
            {
                parser.TextFieldType = FieldType.Delimited;
                parser.SetDelimiters(";");
                while (!parser.EndOfData)
                {
                    string[] fields = parser.ReadFields();
                    foreach (string field in fields)
                    {
                        AllDonnees.Add(field);
                    }
                }
            }

            double t;

            double[] deltas = new double[5];
            double   prix;
            double   tracking_error;
            double   cash;

            for (int i = header.Count + 1; i < AllDonnees.Count; i = i + header.Count)
            {
                t = double.Parse(AllDonnees[i], CultureInfo.CurrentCulture);
                for (int j = 0; j < 5; j++)
                {
                    deltas[j] = double.Parse(AllDonnees[j + 1 + i], CultureInfo.CurrentCulture);
                }
                prix           = double.Parse(AllDonnees[i + 6], CultureInfo.CurrentCulture);
                tracking_error = double.Parse(AllDonnees[i + 7], CultureInfo.CurrentCulture);
                cash           = double.Parse(AllDonnees[i + 8], CultureInfo.CurrentCulture);
                this.Add(t, deltas, prix, tracking_error, cash);
            }
        }
Exemplo n.º 4
0
 public Stock(RecupData data)
 {
     donnees   = new Dictionary <double, List <double> >();
     this.data = data;
     InitializeHeader();
 }