Example #1
0
        public IKLineData GetKLineData(string code, int startDate, int endDate, KLinePeriod period)
        {
            ITradingDayReader openDateReader = dataReaderFactory.OpenDateReader;

            IList <int>       openDates     = openDateReader.GetOpenDates(startDate, endDate);
            int               prevOpenDate  = openDateReader.GetPrevOpenDate(startDate);
            IKLineData        lastKLineData = dataReaderFactory.KLineDataReader.GetData(code, prevOpenDate, prevOpenDate, period);
            List <IKLineData> klineDataList = new List <IKLineData>();

            for (int i = 0; i < openDates.Count; i++)
            {
                int      openDate = openDates[i];
                TickData tickdata = dataReaderFactory.TickDataReader.GetTickData(code, openDate);
                if (tickdata != null)
                {
                    List <double[]>   openTimes = dataProvider.GetOpenTime(code, openDate);
                    OpenTimeUtilsArgs args      = new OpenTimeUtilsArgs(openDate, openDateReader, openTimes, period);
                    KLineData         klineData = DataTransfer_Tick2KLine2.Transfer(tickdata, lastKLineData, args);
                    klineDataList.Add(klineData);
                }
            }
            if (klineDataList.Count == 0)
            {
                return(null);
            }
            return(KLineData.Merge(klineDataList));
        }