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); } } }
public string Proceed() { IList <MainContractInfo> mainContracts = this.dataUpdateHelper.GetMainContractInfos(); List <MainContractInfo> contracts = new List <MainContractInfo>(); CacheUtils_MainContract cache = new CacheUtils_MainContract(mainContracts); ITradingDayReader reader = this.dataUpdateHelper.GetAllTradingDayReader(); string[] varieties = this.dataUpdateHelper.GetAllVarieties(); for (int i = 0; i < varieties.Length; i++) { string variety = varieties[i]; Proceed(variety, cache, contracts, reader); } contracts.Sort(); string path = dataUpdateHelper.GetPath_MainFutures(); string[] contents = new string[contracts.Count]; for (int i = 0; i < contracts.Count; i++) { contents[i] = contracts[i].ToString(); } File.WriteAllLines(path, contents); return(""); }