Exemple #1
0
        public List <double> GetStartTimes(int startDate, int endDate)
        {
            ITradingDayReader openDateCache = GetTradingDayCache();
            int startIndex = openDateCache.GetTradingDayIndex(startDate);
            int endIndex   = openDateCache.GetTradingDayIndex(endDate);

            return(startTimes.GetRange(startIndex, endIndex - startIndex + 1));
        }
Exemple #2
0
        public string Proceed()
        {
            if (overwrite)
            {
                return(Proceed_Overwrite());
            }
            ITradingDayReader    openDateReader = this.dataUpdateHelper.GetAllTradingDayReader();
            KLineDataLastEndInfo lastEndInfo;
            IKLineData           lastKLineData = null;

            //string path = dataUpdateHelper.GetPath_KLineData(code, date, klinePeriod);
            for (int i = 0; i < dates.Count; i++)
            {
                int date = dates[i];
                if (i == 0)
                {
                    lastEndInfo = GetLastEndInfo(date);
                }
                else
                {
                    if (openDateReader.GetTradingDayIndex(date) - openDateReader.GetTradingDayIndex(dates[i - 1]) == 1)
                    {
                        if (lastKLineData != null)
                        {
                            lastEndInfo.lastEndPrice = lastKLineData.Arr_End[lastKLineData.Length - 1];
                            lastEndInfo.lastEndHold  = lastKLineData.Arr_Hold[lastKLineData.Length - 1];
                        }
                        else
                        {
                            lastEndInfo = GetLastEndInfo(date);
                        }
                    }
                    else
                    {
                        lastEndInfo = GetLastEndInfo(date);
                    }
                }
                Step_KLineData_OneDay step_klineData = new Step_KLineData_OneDay(dataUpdateHelper, codeInfo, date, KLinePeriod.KLinePeriod_1Minute, lastEndInfo.lastEndPrice, lastEndInfo.lastEndHold);
                step_klineData.Proceed();
                if (step_klineData.KlineData != null)
                {
                    lastKLineData = step_klineData.KlineData;
                }
            }
            if (!updateFillUp && updatedDataInfo != null)
            {
                updatedDataInfo.WriteUpdateInfo_KLine(codeInfo.Code, KLinePeriod.KLinePeriod_1Minute, dates[dates.Count - 1]);
                updatedDataInfo.Save();
            }
            return("更新完毕" + GetDesc());
        }
Exemple #3
0
        public List <TradingSession> LoadTradingSessions(string code)
        {
            List <TradingSession> dayStartTimes = this.LoadUpdatedTradingSessions(code);

            ITradingDayReader openDateReader = this.LoadTradingDayReader();
            int firstIndex = 0;

            if (dayStartTimes != null && dayStartTimes.Count != 0)
            {
                int lastDate = dayStartTimes[dayStartTimes.Count - 1].TradingDay;
                if (lastDate == openDateReader.LastTradingDay)
                {
                    return(null);
                }
                int lastIndex = openDateReader.GetTradingDayIndex(lastDate);
                firstIndex = lastIndex + 1;
            }
            List <int>            openDates        = openDateReader.GetAllTradingDays();
            List <TradingSession> updateStartTimes = CalcDayOpenTime(code, openDates, firstIndex, openDates.Count - 1);

            List <TradingSession> result = new List <TradingSession>();

            if (dayStartTimes != null)
            {
                result.AddRange(dayStartTimes);
            }
            result.AddRange(updateStartTimes);
            return(result);
        }
Exemple #4
0
        public List <double> GetStartTimes(int startDate)
        {
            ITradingDayReader openDateCache = GetTradingDayCache();
            int startIndex = openDateCache.GetTradingDayIndex(startDate);
            int count      = tradingDays.Count - startIndex;

            return(startTimes.GetRange(startIndex, count));
        }
Exemple #5
0
        private int GetLastUpdatedIndex(IList <ITradingTime> dayStartTimes)
        {
            if (dayStartTimes == null || dayStartTimes.Count == 0)
            {
                return(-1);
            }
            int lastDate = dayStartTimes[dayStartTimes.Count - 1].TradingDay;
            ITradingDayReader openDateReader = this.dataUpdateHelper.GetAllTradingDayReader();
            int lastIndex = openDateReader.GetTradingDayIndex(lastDate);

            return(lastIndex);
        }
Exemple #6
0
        private int GetLastUpdatedIndex(List <TradingSession> dayStartTimes)
        {
            if (dayStartTimes == null || dayStartTimes.Count == 0)
            {
                return(-1);
            }
            int lastDate = dayStartTimes[dayStartTimes.Count - 1].TradingDay;
            ITradingDayReader openDateReader = this.LoadTradingDayReader();
            int lastIndex = openDateReader.GetTradingDayIndex(lastDate);

            return(lastIndex);
        }
Exemple #7
0
        private int GetLastTradingDayIndex(CodeInfo codeInfo, ITradingDayReader openDateReader)
        {
            int codeLastDate = codeInfo.End;

            if (codeLastDate <= 0)
            {
                return(openDateReader.GetAllTradingDays().Count - 1);
            }
            int lastTradingDay = openDateReader.LastTradingDay;

            lastTradingDay = codeLastDate > lastTradingDay ? lastTradingDay : codeLastDate;

            int index = openDateReader.GetTradingDayIndex(lastTradingDay);

            if (index >= 0)
            {
                return(index);
            }
            int date = openDateReader.GetPrevTradingDay(lastTradingDay);

            return(openDateReader.GetTradingDayIndex(date));
        }
Exemple #8
0
        private int GetFirstTradingDayIndex(CodeInfo codeInfo, ITradingDayReader openDateReader)
        {
            int codeFirstDate = codeInfo.Start;

            if (codeFirstDate < 0)
            {
                return(0);
            }
            int firstTradingDay = openDateReader.FirstTradingDay;

            firstTradingDay = codeFirstDate > firstTradingDay ? codeFirstDate : firstTradingDay;

            int index = openDateReader.GetTradingDayIndex(firstTradingDay);

            if (index >= 0)
            {
                return(index);
            }
            int date = openDateReader.GetNextTradingDay(firstTradingDay);

            return(openDateReader.GetTradingDayIndex(date));
        }