public List <IStep> GetAllSteps() { List <IStep> steps = new List <IStep>(); UpdatedDataInfo updatedDataInfo = new UpdatedDataInfo(DataConst.CSVPATH); if (DateTime.Now.Hour > 19) { Step_SinaDownload step = new Step_SinaDownload(); steps.Add(step); } Step_TradingDay step_TradingDay = new Step_TradingDay(); steps.Add(step_TradingDay); Step_CodeInfo step_CodeInfo = new Step_CodeInfo(); List <CodeInfo> allCodes = step_CodeInfo.GetAllCodes(); steps.Add(step_CodeInfo); GetTradingTime(steps, allCodes, false); GetTickSteps(steps, updatedDataInfo, allCodes); GetKLineDataSteps(steps, updatedDataInfo, allCodes); ///* // * 在准备更新的时候会将所有更新信息索引一次 // * 所以在准备完更新后保存一次 // */ //updatedDataInfo.Save(); return(steps); }
private void GetTickSteps(List <IStep> steps, UpdatedDataInfo updatedDataInfo, List <CodeInfo> allCodes) { //List<CodeInfo> codes = dataUpdateHelper.GetNewCodes(); //必须要先更新合约,再更新指数 GetTickSteps(steps, GetNotIndexCodes(allCodes), updatedDataInfo); GetTickSteps(steps, GetIndexCodes(allCodes), updatedDataInfo); }
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); }
public Step_KLineData(CodeInfo codeInfo, List <int> dates, DataUpdateHelper dataUpdateHelper, UpdatedDataInfo updatedDataInfo, bool updateFillUp) { this.codeInfo = codeInfo; this.dates = dates; this.dataUpdateHelper = dataUpdateHelper; this.updatedDataInfo = updatedDataInfo; this.updateFillUp = updateFillUp; }
private void GetTickSteps(List <IStep> steps, UpdatedDataInfo updatedDataInfo, List <CodeInfo> allCodes) { for (int i = 0; i < allCodes.Count; i++) { Step_TickData_Code step = new Step_TickData_Code(allCodes[i].Code); steps.Add(step); } }
private void GetKLineDataSteps(List <IStep> steps, UpdatedDataInfo updatedDataInfo, List <CodeInfo> allCodes) { for (int i = 0; i < allCodes.Count; i++) { Step_KLineData step = new Step_KLineData(allCodes[i].Code); steps.Add(step); } }
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); } }
public List <IStep> GetAllSteps() { //return GetAllStep_Varieties(); if (dataProvider.GetAppointUpdate() != null) { return(GetAllStep_UpdateAppoint()); } List <IStep> steps = new List <IStep>(); UpdatedDataInfo updatedDataInfo = new UpdatedDataInfo(targetDataPath); Step_CodeInfo step_CodeInfo = new Step_CodeInfo(dataUpdateHelper); List <CodeInfo> allCodes = step_CodeInfo.GetAllCodes(); steps.Add(step_CodeInfo); steps.Add(new Step_TradingDay(dataUpdateHelper)); GetTradingTime(steps, allCodes, false); //GetTradingTime(steps, allCodes, true); GetTickSteps(steps, updatedDataInfo, allCodes); GetKLineDataSteps(steps, updatedDataInfo, allCodes); //GetTickDataSteps_Day_All(steps, 20180102, allCodes); //GetTickDataSteps_Day_All(steps, 20170719, allCodes); //GetTickDataSteps_Day_All(steps, 20170720, allCodes); //GetTickDataSteps_Day_All(steps, 20170721, allCodes); //GetKLineDataSteps_Day(steps, 20180102, allCodes); //GetKLineDataSteps_Day(steps, 20170719, allCodes); //GetKLineDataSteps_Day(steps, 20170720, allCodes); //GetKLineDataSteps_Day(steps, 20170721, allCodes); //更新主力合约信息 Step_MainFutures step_MainFutures = new Step_MainFutures(this.dataUpdateHelper); steps.Add(step_MainFutures); ///* // * 在准备更新的时候会将所有更新信息索引一次 // * 所以在准备完更新后保存一次 // */ //updatedDataInfo.Save(); return(steps); }
public void Save(UpdatedDataInfo updatedDataInfo) { updatedDataInfo.Save(); }
private void GetKLineDataSteps(List <IStep> steps, CodeInfo codeInfo, List <int> tradingDays, UpdatedDataInfo updatedDataInfo) { int stepCount = tradingDays.Count / DAYS_EVERYKLINESTEP; int lastStepUpdateCount = tradingDays.Count % DAYS_EVERYKLINESTEP; if (lastStepUpdateCount != 0) { stepCount++; } else { lastStepUpdateCount = DAYS_EVERYKLINESTEP; } List <int> openDates = tradingDays; for (int i = 0; i < stepCount; i++) { Step_KLineData step; if (i != stepCount - 1) { step = new Step_KLineData(codeInfo, openDates.GetRange(i * DAYS_EVERYKLINESTEP, DAYS_EVERYKLINESTEP), dataUpdateHelper, null, updateFillUp); } else { step = new Step_KLineData(codeInfo, openDates.GetRange(i * DAYS_EVERYKLINESTEP, lastStepUpdateCount), dataUpdateHelper, updatedDataInfo, updateFillUp); } steps.Add(step); } }
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); } }