Ejemplo n.º 1
0
        public string Proceed()
        {
            string path = dataUpdateHelper.GetPath_KLineData(codeInfo.Code, date, klinePeriod);
            //if (!(codeInfo.Code.EndsWith("0000") || codeInfo.Code.EndsWith("MI")))
            //if (!overwrite && File.Exists(path))
            //    return codeInfo.Code + "-" + date + "的K线数据已存在";

            TickData tickData = (TickData)dataUpdateHelper.GetUpdatedTickData(codeInfo.Code, date);

            if (tickData == null)
            {
                tickData = (TickData)dataUpdateHelper.GetNewTickData(codeInfo.ServerCode, date);
            }
            //tick数据没有,则不生成对应K线数据
            if (tickData == null)
            {
                string msg = codeInfo.Code + "-" + date + "的tick数据不存在";
                LogHelper.Warn(GetType(), msg);
                return(msg);
            }

            IList <double[]> tradingPeriod = dataUpdateHelper.GetTradingTime(codeInfo.Code, date).TradingPeriods;

            //List<double[]> klineTimes = TradingTimeUtils.GetKLineTimeList_Full(tradingPeriod, KLinePeriod.KLinePeriod_1Minute);
            //timeListGetter.GetKLineTimeList(code, date, klinePeriod);
            this.klineData = DataTransfer_Tick2KLine.Transfer(tickData, tradingPeriod, KLinePeriod.KLinePeriod_1Minute, lastEndPrice, lastEndHold);
            CsvUtils_KLineData.Save(path, klineData);
            return("更新" + codeInfo.Code + "-" + date + "的" + klinePeriod + "K线完成");
        }
Ejemplo n.º 2
0
        private IKLineData ReadKLineData()
        {
            string klinepath = path + "\\kline\\1minute\\" + code + "_1MINUTE_" + date + ".csv";

            if (!File.Exists(klinepath))
            {
                return(null);
            }
            return(CsvUtils_KLineData.Load(klinepath));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 得到单日的K线数据
        /// </summary>
        /// <param name="code"></param>
        /// <param name="date"></param>
        /// <param name="period"></param>
        /// <returns></returns>
        public virtual IKLineData GetKLineData(string code, int date, KLinePeriod period)
        {
            string path = CsvHistoryData_PathUtils.GetKLineDataPath(GetCsvDataPath(), code, date, period);

            if (!File.Exists(path))
            {
                return(null);
            }
            return(CsvUtils_KLineData.Load(path));
        }
Ejemplo n.º 4
0
        public void TestToString()
        {
            string res = TestCaseManager.LoadTestCaseFile(GetType(), "KLineData_M01_1Minute");

            string[]   lines     = res.Split('\r');
            IKLineData klineData = CsvUtils_KLineData.LoadByLines(lines);

            for (int i = 0; i < lines.Length; i++)
            {
                klineData.BarPos = i;
                Assert.AreEqual(lines[i].Trim(), klineData.ToString());
            }
        }
Ejemplo n.º 5
0
        private IKLineData DownloadKLine(string code)
        {
            string path = pathutils.GetKLinePath(code);

            if (File.Exists(path))
            {
                IKLineData klineData       = CsvUtils_KLineData.Load(path);
                int        lastUpdatedDate = (int)klineData.Arr_Time[klineData.Length - 1];
                AppendKLineData(code, path, lastUpdatedDate);
            }
            else
            {
                AppendKLineData(code, path, -1);
            }
            return(CsvUtils_KLineData.Load(path));
        }
Ejemplo n.º 6
0
        private void Proceed(int date)
        {
            ITickData tickData = CsvUtils_TickData.Load(Step_TickData_Code.GetTickPath(code, date));

            //tick数据没有,则不生成对应K线数据
            if (tickData == null)
            {
                return;
            }

            IList <double[]> tradingPeriod = Step_TradingTime.GetTradingTime(date).TradingPeriods;
            IKLineData       klineData     = DataTransfer_Tick2KLine.Transfer(tickData, tradingPeriod, KLinePeriod.KLinePeriod_1Minute, 0, 0);

            string path = DataConst.CSVPATH + code + "\\kline\\1MINUTE\\" + code + "_1MINUTE_" + date + ".csv";

            CsvUtils_KLineData.Save(path, klineData);
        }
Ejemplo n.º 7
0
        private KLineData GetKLineData_1Min()
        {
            string path = TestCaseManager.GetTestCasePath(GetType(), "KLineData_M01_1Minute");

            return((KLineData)CsvUtils_KLineData.Load(path));
        }
Ejemplo n.º 8
0
 public static KLineData GetKLineData(String resource)
 {
     string[] lines = resource.Split('\r');
     return((KLineData)CsvUtils_KLineData.LoadByLines(lines));
 }