Exemplo n.º 1
0
        private List <IStep> GetAllStep_Varieties()
        {
            List <IStep>    steps         = new List <IStep>();
            Step_CodeInfo   step_CodeInfo = new Step_CodeInfo(dataUpdateHelper);
            List <CodeInfo> allCodes      = step_CodeInfo.GetAllCodes();

            allCodes = FilterCodeInfo(allCodes, new string[] { "RB", "HC", "BU" });
            GetTradingTime(steps, allCodes, true);
            UpdatedDataInfo updatedDataInfo = new UpdatedDataInfo(targetDataPath);

            ITradingDayReader tradingDayReader = dataUpdateHelper.GetAllTradingDayReader();

            for (int i = 0; i < allCodes.Count; i++)
            {
                CodeInfo codeInfo  = allCodes[i];
                int      startDate = codeInfo.Start;
                if (startDate == 0)
                {
                    startDate = tradingDayReader.FirstTradingDay;
                }

                int endDate = codeInfo.End;
                if (endDate <= 0)
                {
                    endDate = tradingDayReader.LastTradingDay;
                }
                List <int> tradingDays = new List <int>();
                tradingDays.AddRange(tradingDayReader.GetTradingDays(startDate, endDate));
                GetKLineDataSteps(steps, codeInfo, tradingDays, updatedDataInfo);
            }
            return(steps);
        }
Exemplo n.º 2
0
        private void Proceed(string variety, CacheUtils_MainContract cache, List <MainContractInfo> contracts, ITradingDayReader reader)
        {
            MainContractInfo contractInfo = cache.GetRecentMainContract(variety);

            if (contractInfo == null)
            {
                List <int>  tradingDays = reader.GetAllTradingDays();
                MainFutures mf          = scan.Scan(variety, tradingDays);
                contracts.AddRange(mf.mainFutures);
            }
            else
            {
                int tradingDay     = contractInfo.End;
                int nextTradingDay = reader.GetNextTradingDay(tradingDay);
                if (nextTradingDay < 0)
                {
                    contracts.AddRange(cache.GetMainContractInfos(variety));
                    return;
                }
                List <int>  allTradingDays = reader.GetAllTradingDays();
                IList <int> tradingDays    = reader.GetTradingDays(nextTradingDay, allTradingDays[allTradingDays.Count - 1]);
                MainFutures mf             = scan.Scan(variety, tradingDays);
                if (mf.mainFutures.Count > 0)
                {
                    MainContractInfo firstMf = mf.mainFutures[0];
                    if (firstMf.Code == contractInfo.Code)
                    {
                        contractInfo.End = firstMf.End;
                        mf.mainFutures.RemoveAt(0);
                    }
                    contracts.AddRange(cache.GetMainContractInfos(variety));
                    contracts.AddRange(mf.mainFutures);
                }
            }
        }
Exemplo n.º 3
0
        private void GetTickSteps(List <IStep> steps, List <CodeInfo> codes, UpdatedDataInfo updatedDataInfo)
        {
            for (int i = 0; i < codes.Count; i++)
            {
                CodeInfo   codeInfo = codes[i];
                string     code     = codeInfo.Code;
                List <int> notUpdatedTradingDays;

                ITradingDayReader tradingDayReader = dataUpdateHelper.GetAllTradingDayReader();
                int lastUpdatedTickDate            = updatedDataInfo.GetLastUpdatedTickData(code);
                if (!updateFillUp && lastUpdatedTickDate >= 0)
                {
                    int endDate;
                    if (codeInfo.End <= 0)
                    {
                        endDate = tradingDayReader.LastTradingDay;
                    }
                    else if (codeInfo.End < tradingDayReader.LastTradingDay)
                    {
                        endDate = codeInfo.End;
                    }
                    else
                    {
                        endDate = tradingDayReader.LastTradingDay;
                    }

                    if (lastUpdatedTickDate >= endDate)
                    {
                        continue;
                    }
                    int startDate = tradingDayReader.GetNextTradingDay(lastUpdatedTickDate);
                    if (startDate < 0)
                    {
                        continue;
                    }
                    IList <int> days = tradingDayReader.GetTradingDays(startDate, endDate);
                    if (days.Count == 0)
                    {
                        continue;
                    }
                    notUpdatedTradingDays = new List <int>(days);
                }
                else
                {
                    notUpdatedTradingDays = dataUpdateHelper.GetNotUpdateTradingDays_TickData(code, updateFillUp);
                    if (notUpdatedTradingDays == null || notUpdatedTradingDays.Count == 0)
                    {
                        //updatedDataInfo.WriteUpdateInfo_Tick(code, tradingDayReader.LastTradingDay);
                        continue;
                    }

                    int startDate      = notUpdatedTradingDays[0];
                    int lastUpdateDate = tradingDayReader.GetPrevTradingDay(startDate);
                    //updatedDataInfo.WriteUpdateInfo_Tick(code, lastUpdateDate);
                }
                GetTickSteps(steps, codeInfo, notUpdatedTradingDays, updatedDataInfo);
            }
        }
Exemplo n.º 4
0
        private List <int> GetCodeOpenDates(string code)
        {
            CodeInfo codeInfo = this.dataLoader.GetCodeInfo(code);

            if (codeInfo == null)
            {
                codeInfo = dic_Id_CodeInfo[code];
            }
            List <int> list = new List <int>();

            list.AddRange(tradingDayReader.GetTradingDays(codeInfo.Start, codeInfo.End));
            return(list);
        }
Exemplo n.º 5
0
        private void GetKLineDataSteps(List <IStep> steps, UpdatedDataInfo updatedDataInfo, List <CodeInfo> allCodes)
        {
            List <CodeInfo> codes = allCodes;

            for (int i = 0; i < codes.Count; i++)
            {
                CodeInfo codeInfo = codes[i];
                string   code     = codeInfo.Code;
                //List<int> notUpdatedTradingDays = new List<int>();
                //notUpdatedTradingDays.AddRange(this.dataUpdateHelper.GetAllHolidays());
                //notUpdatedTradingDays.Remove(20171009);
                //Delete(code, notUpdatedTradingDays);
                List <int>        notUpdatedTradingDays;
                ITradingDayReader tradingDayReader = dataUpdateHelper.GetAllTradingDayReader();
                int lastUpdatedKLineDate           = updatedDataInfo.GetLastUpdatedKLineData(code, KLinePeriod.KLinePeriod_1Minute);
                if (!updateFillUp && lastUpdatedKLineDate >= 0)
                {
                    int endDate;
                    if (codeInfo.End <= 0)
                    {
                        endDate = tradingDayReader.LastTradingDay;
                    }
                    else if (codeInfo.End < tradingDayReader.LastTradingDay)
                    {
                        endDate = codeInfo.End;
                    }
                    else
                    {
                        endDate = tradingDayReader.LastTradingDay;
                    }

                    if (lastUpdatedKLineDate >= endDate)
                    {
                        continue;
                    }
                    int startDate = tradingDayReader.GetNextTradingDay(lastUpdatedKLineDate);
                    if (startDate < 0)
                    {
                        continue;
                    }
                    IList <int> days = tradingDayReader.GetTradingDays(startDate, endDate);
                    if (days.Count == 0)
                    {
                        continue;
                    }
                    notUpdatedTradingDays = new List <int>(days);
                }
                else
                {
                    notUpdatedTradingDays = dataUpdateHelper.GetNotUpdateTradingDays_KLineData(code, updateFillUp);
                    if (notUpdatedTradingDays == null || notUpdatedTradingDays.Count == 0)
                    {
                        updatedDataInfo.WriteUpdateInfo_KLine(code, KLinePeriod.KLinePeriod_1Minute, tradingDayReader.LastTradingDay);
                        continue;
                    }
                    int startDate      = notUpdatedTradingDays[0];
                    int lastUpdateDate = tradingDayReader.GetPrevTradingDay(startDate);
                    updatedDataInfo.WriteUpdateInfo_KLine(code, KLinePeriod.KLinePeriod_1Minute, lastUpdateDate);
                }
                GetKLineDataSteps(steps, codeInfo, notUpdatedTradingDays, updatedDataInfo);
            }
        }