示例#1
0
        private void AddSteps_TickData(List <IStep> steps)
        {
            ITickDataStore tickDataStore = dataStore.CreateTickDataStore();

            List <CodeInfo> allInstruments = historyData.GetInstruments();
            List <int>      allTradingDays = historyData.GetTradingDays();

            CacheUtils_TradingDay tradingDayCache = new CacheUtils_TradingDay(allTradingDays);

            for (int i = 0; i < allInstruments.Count; i++)
            //for (int i = 0; i < 10; i++)
            {
                CodeInfo instrument = allInstruments[i];

                //if (!(instrument.Exchange == "SQ" && instrument.Code.EndsWith("0000")))
                //    continue;

                int lastTradingDay = instrument.End;
                if (lastTradingDay <= 0)
                {
                    lastTradingDay = tradingDayCache.LastTradingDay;
                }
                int lastUpdatedDate = updatedDataInfo.GetLastUpdatedTickData(instrument.Code);
                if (lastUpdatedDate < instrument.Start)
                {
                    lastUpdatedDate = tradingDayCache.GetPrevTradingDay(instrument.Start);
                }

                List <int> allDays;
                if (!isFillUp)
                {
                    if (lastUpdatedDate >= lastTradingDay)
                    {
                        continue;
                    }
                    int startDate = tradingDayCache.GetNextTradingDay(lastUpdatedDate);
                    //如果不填充数据,直接根据最新交易日期和最后更新日期
                    int endDate = instrument.End;
                    if (endDate <= 0)
                    {
                        endDate = allTradingDays[allTradingDays.Count - 1];
                    }

                    //20171015 ww 在不全面更新数据情况下,如果最新的交易日比合约截止时间更新,则不再更新该合约数据
                    int firstNewTradingDay = newTradingDays.Count == 0 ? allTradingDays[allTradingDays.Count - 1] : newTradingDays[0];
                    if (firstNewTradingDay > endDate)
                    {
                        continue;
                    }

                    IList <int> tradingDays = tradingDayCache.GetTradingDays(lastUpdatedDate, endDate);
                    if (tradingDays == null || tradingDays.Count == 0)
                    {
                        continue;
                    }
                    allDays = new List <int>();
                    allDays.AddRange(tradingDays);
                    //allTradingDays
                }
                else
                {
                    //如果填充所有数据
                    List <int> storedAllDays = tickDataStore.GetAllDays(instrument.Code);
                    allDays = GetAllNotUpdateTickData(instrument, tradingDayCache, storedAllDays, isFillUp);
                    if (allDays == null)
                    {
                        continue;
                    }
                }

                AddSteps_TickData_Instrument(steps, instrument.Code, allDays);
            }
        }
示例#2
0
 public int GetNextTradingDay()
 {
     return(cache_TradingDay.GetNextTradingDay(tradingDay));
 }