private void AddSteps_KLineData(List <IStep> steps) { List <CodeInfo> instruments = historyData.GetInstruments(); List <int> tradingDays = historyData.GetTradingDays(); CacheUtils_TradingDay cache = new CacheUtils_TradingDay(tradingDays); for (int i = 0; i < instruments.Count; i++) { CodeInfo codeInfo = instruments[i]; if (codeInfo.End == 0 || codeInfo.End >= 20170718) { AddSteps_KLineData_Instrument(steps, codeInfo, cache); } } }
public Step_UpdateTradingDays(IPlugin_HistoryData historyData, IDataStore dataStore) { this.tradingDayStore = dataStore.CreateTradingDayStore(); this.tradingDays = historyData.GetTradingDays(); List <int> historyTradingDays = tradingDayStore.Load(); this.newTradingDays = new List <int>(); CacheUtils_TradingDay cache = new CacheUtils_TradingDay(historyTradingDays); for (int i = 0; i < tradingDays.Count; i++) { int tradingDay = tradingDays[i]; if (!cache.IsTrade(tradingDay)) { newTradingDays.Add(tradingDay); } } newTradingDays.Sort(); }
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); } }