Exemplo n.º 1
0
        static void PerfTest2(DataApi dapi)
        {
            var codes = new List <String>();

            var result = CSVReader.ParseCSV(File.ReadAllText(@"d:\\tmp\\000300.SH.csv"));

            foreach (var line in result)
            {
                codes.Add(line[3]);
            }
            codes.RemoveAt(0);

            dapi.Subscribe(new String[] { "000001.SH" });
            dapi.Subscribe(codes.ToArray());

            var begin_time = DateTime.Now;

            foreach (var bar in dapi.GetDailyBar("000001.SH").Value)
            {
                if (bar.Date < 20180101 || bar.Date > 20180501)
                {
                    continue;
                }
                foreach (var code in codes)
                {
                    dapi.GetBar(code, "1m", bar.Date);
                }
            }
            var end_time = DateTime.Now;

            Console.Out.WriteLine(String.Format("time: {0}", (end_time - begin_time).TotalSeconds));
        }
Exemplo n.º 2
0
 static void TestDataApi(DataApi dapi)
 {
     {
         var r = dapi.GetBar("000001.SH", "1m", 0, true);
         if (r.Value != null)
         {
             foreach (var bar in r.Value)
             {
                 Console.WriteLine(bar.Code + "|"
                                   + bar.Date + "|" + bar.Time + "|"
                                   + bar.Open + "|" + bar.High + "|"
                                   + bar.Low + "|" + bar.Close + "|"
                                   + bar.Volume + "|" + bar.Turnover);
             }
             Console.WriteLine("bars : " + r.Value.Length);
         }
         else
         {
             Console.WriteLine("GetBar error:" + r.Msg);
         }
     }
     {
         var r = dapi.GetTick("600000.SH");
         if (r.Value != null)
         {
             foreach (var tick in r.Value)
             {
                 Console.WriteLine(tick.Code + "|"
                                   + tick.Date + "|" + tick.Time + "|"
                                   + tick.Open + "|" + tick.High + "|"
                                   + tick.Low + "|" + tick.Close + "|"
                                   + tick.Volume + "|" + tick.Turnover);
             }
             Console.Write("ticks: " + r.Value.Length);
         }
     }
     {
         var r = dapi.GetDailyBar("000001.SH", "", true);
         if (r.Value != null)
         {
             foreach (var bar in r.Value)
             {
                 Console.WriteLine(bar.Code + "|"
                                   + bar.Date + "|"
                                   + bar.Open + "|" + bar.High + "|"
                                   + bar.Low + "|" + bar.Close + "|"
                                   + bar.Volume + "|" + bar.Turnover);
             }
             Console.WriteLine("dailybars : " + r.Value.Length);
         }
         else
         {
             Console.WriteLine("GetBar error:" + r.Msg);
         }
     }
 }