Exemplo n.º 1
0
        public static void WriteRowData(int numw)
        {
            TickData.initialize();
            List <string> data = new List <string>();

            using (System.IO.StreamReader sr = new System.IO.StreamReader("tick.csv", Encoding.UTF8, false))
            {
                try
                {
                    Form1.Form1Instance.setLabel("reading data");
                    int num = 0;
                    foreach (var line in File.ReadLines("tick.csv"))
                    {
                        data.Add(line);
                        num++;
                    }
                    Form1.Form1Instance.setLabel("Copy " + data.Count.ToString() + " data to a new file.");
                }
                catch (Exception e)
                {
                    System.Windows.Forms.MessageBox.Show(e.ToString());
                }
            }

            using (StreamWriter sw = new StreamWriter("./tick data_new.csv", false, Encoding.Default))
            {
                try
                {
                    Form1.Form1Instance.setLabel("writing data to a new file");
                    int n = 0;
                    for (int i = data.Count - numw; i < data.Count; i++)
                    {
                        sw.WriteLine(data[i]);
                    }
                }
                catch (Exception e)
                {
                    System.Windows.Forms.MessageBox.Show(e.ToString());
                }
            }
        }
Exemplo n.º 2
0
        public static void readTickData(int num_skip)
        {
            if (TickData.price == null)
            {
                TickData.initialize();

                using (System.IO.StreamReader sr = new System.IO.StreamReader("tick.csv", Encoding.UTF8, false))
                {
                    try
                    {
                        Form1.Form1Instance.setLabel("reading data");
                        int num = 0;
                        foreach (var line in File.ReadLines("tick.csv"))
                        {
                            if (num_skip <= num)
                            {
                                var e = line.Split(',');
                                TickData.time.Add(FromUnixTime(Convert.ToInt64(e[0])));
                                TickData.price.Add(Convert.ToDouble(e[1]));
                                TickData.volume.Add(Convert.ToDouble(e[2]));
                            }
                            num++;
                        }
                        Form1.Form1Instance.setLabel("Tick Data: from-" + time[0].ToString() + ", to-" + time[time.Count - 1].ToString() + ", Num=" + (num - num_skip).ToString());
                    }
                    catch (Exception e)
                    {
                        System.Windows.Forms.MessageBox.Show(e.ToString());
                    }
                }

                calcAveVolAll();
                //calcSpeedAll();
                calcVolaAll();
                dcalcAllMaKairi();
                //Histogram.calcTickCluster(0.33, 499, 100);
            }
        }