Пример #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线完成");
        }
Пример #2
0
        public IKLineData GetKLineData(string code, int startDate, int endDate, KLinePeriod klinePeriod)
        {
            List <double> klineTimeList     = new List <double>();
            float         yesterdayEndPrice = 0f;
            int           yesterdayEndHold  = 0;

            return(DataTransfer_Tick2KLine.Transfer(GetTickData(code, date), klineTimeList, yesterdayEndPrice, yesterdayEndHold));
        }
Пример #3
0
        public IKLineData LoadKLineData(string code, int date, KLinePeriod klinePeriod, float lastEndPrice, int lastEndHold)
        {
            KLineTimeListGetter timeListGetter = new KLineTimeListGetter(LoadTradingDayReader(), this.dataLoader_TradingSessionDetail);
            ITickData           tickData       = this.LoadUpdatedTickData(code, date);

            /*
             * 此处不处理tickData为空的情况
             * 在DataTransfer_Tick2KLine.Transfer里处理tickData为空的情况
             */
            List <double> klineTimes = timeListGetter.GetKLineTimeList(code, date, klinePeriod);
            IKLineData    klineData  = DataTransfer_Tick2KLine.Transfer(tickData, klineTimes, lastEndPrice, lastEndHold);

            return(klineData);
        }
Пример #4
0
        private IKLineData LoadKLineData_Second(string code, int date, KLinePeriod period)
        {
            TickData tickData = dataReader.TickDataReader.GetTickData(code, date);

            if (tickData == null)
            {
                return(null);
            }
            float            lastEndPrice   = this.GetLastEndPrice(code, date);
            int              lastEndHold    = this.GetLastEndHold(code, date);
            IList <double[]> tradingPeriods = dataReader.CreateTradingTimeReader(code).GetTradingTime(date).TradingPeriods;

            return(DataTransfer_Tick2KLine.Transfer(tickData, tradingPeriods, period, lastEndPrice, lastEndHold));
        }
Пример #5
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);
        }
Пример #6
0
        public static IKLineData GetKLineData(string code, int start, int end, KLinePeriod period, List <double[]> openTime)
        {
            DataReaderFactory fac        = ResourceLoader.GetDefaultDataReaderFactory();
            ITickDataReader   tickReader = fac.TickDataReader;
            IList <int>       dates      = fac.OpenDateReader.GetOpenDates(start, end);
            List <TickData>   dataList   = new List <TickData>();

            for (int i = 0; i < dates.Count; i++)
            {
                int      date     = dates[i];
                TickData tickData = tickReader.GetTickData(code, date);
                if (tickData == null)
                {
                    continue;
                }
                dataList.Add(tickData);
            }
            return(DataTransfer_Tick2KLine.Transfer(dataList, period, openTime));
        }