コード例 #1
0
ファイル: RowDataAll.cs プロジェクト: itamarkr5/19.7-UTD
 public RowdataAll(RowdataAll r)
 {
     this.datetime = r.datetime;
     this.ask1 = r.ask1;
     this.bid1 = r.bid1;
     this.ask2 = r.ask2;
     this.bid2 = r.bid2;
     this.ask3 = r.ask3;
     this.bid3 = r.bid3;
     this.askV = r.askV;
     this.bidV = r.bidV;
     this.dir = r.dir;
     this.isTrade = r.isTrade;
 }
コード例 #2
0
ファイル: fileToPNG.cs プロジェクト: itamarkr5/19.7-UTD
        public List<RowdataAll> datacollector(string path)
        {
            StreamReader reader = new StreamReader(path);
            Dictionary<String, int> headersIDs = new Dictionary<string, int>();
            String line = reader.ReadLine();
            String[] headers = line.Split(',');

            for (int i = 0; i < headers.Length; i++)
            {
                headersIDs.Add(headers[i], i);
            }
            List<RowdataAll> rowdatalist = new List<RowdataAll>();

            RowdataAll r = new RowdataAll();
            int counter = 0;
            bool start = true;
            double ask1 = 0;
            double ask2 = 0;
            double ask3 = 0;
            double bid1 = 0;
            double bid2 = 0;
            double bid3 = 0;
            DateTime time = new DateTime();
            while ((line = reader.ReadLine()) != null)
            {

                String[] fields = line.Split(',');
                r.datetime = DateTime.Parse(fields[headersIDs["DateTime"]].ToString());
                r.ask1 = double.Parse(fields[headersIDs["ask1"]].ToString());
                r.bid1 = double.Parse(fields[headersIDs["bid1"]].ToString());
                r.ask2 = double.Parse(fields[headersIDs["ask2"]].ToString());
                r.bid2 = double.Parse(fields[headersIDs["bid2"]].ToString());
                r.ask3 = double.Parse(fields[headersIDs["ask3"]].ToString());
                r.bid3 = double.Parse(fields[headersIDs["bid3"]].ToString());
                r.isTrade = int.Parse(fields[headersIDs["isTrade"]].ToString());
                r.askV = int.Parse(fields[headersIDs["ask1volume"]].ToString());
                r.bidV = int.Parse(fields[headersIDs["bid1Volume"]].ToString());
                r.dir = 0;
                if (start)
                {
                    start = false;
                    time = new DateTime(r.datetime.Year,r.datetime.Month,r.datetime.Day,r.datetime.Hour,r.datetime.Minute,r.datetime.Second);

                    counter++;
                    ask1 += r.ask1;
                    ask2 += r.ask2;
                    ask3 += r.ask3;
                    bid1 += r.bid1;
                    bid2 += r.bid2;
                    bid3 += r.bid3;

                }

                if (time.Minute - r.datetime.Minute < 30)
                {
                    counter++;
                    ask1 += r.ask1;
                    ask2 += r.ask2;
                    ask3 += r.ask3;
                    bid1 += r.bid1;
                    bid2 += r.bid2;
                    bid3 += r.bid3;
                }
                else
                {
                    RowdataAll finalr = new RowdataAll();

                    finalr.ask1 = ask1 / counter;
                    finalr.ask2 = ask2 / counter;
                    finalr.ask3 = ask3 / counter;
                    finalr.bid1 = bid1 / counter;
                    finalr.bid2 = bid2 / counter;
                    finalr.bid3 = bid3 / counter;
                    finalr.datetime = time;
                    counter = 0;
                    ask1 = r.ask1;
                    ask2 = r.ask2;
                    ask3 = r.ask3;
                    bid1 = r.bid1;
                    bid2 = r.bid2;
                    bid3 = r.bid3;

                    time = new DateTime(r.datetime.Year, r.datetime.Month, r.datetime.Day, r.datetime.Hour, r.datetime.Minute, r.datetime.Second);
                    rowdatalist.Add(finalr);
                }

            }
            return rowdatalist;

        }