private IList <TaskMessage> ComputeStockState(Task.Interface.IMessageSender sender) { this.Log().Info("开始计算个股形态"); IList <stockcategory> cateList = cateService.FindAll(); IList <TaskMessage> msgList = new List <TaskMessage>(); TechCycle[] cycleList = new TechCycle[] { TechCycle.day, TechCycle.week, TechCycle.month }; foreach (var category in cateList) { IList <stock> stockList = stockService.GetStockByCategory(category.code); foreach (var stock in stockList) { this.Log().Info("计算股票:" + stock.name); foreach (var cycle in cycleList) { var task1 = new IndexTask { type = ObjectType.Stock, code = stock.code, cycle = cycle }; sender.Send(JsonConvert.SerializeObject(task1)); Thread.Sleep(100); } } } //string[] list = new string[] { "0600265" }; //foreach (var code in list) //{ // foreach (var cycle in cycleList) // { // var task1 = new IndexTask // { // type = ObjectType.Stock, // code = code, // cycle = cycle // }; // sender.Send(JsonConvert.SerializeObject(task1)); // } //} return(msgList); }
public void Execute(IJobExecutionContext context) { LoggingExtensions.Logging.Log.InitializeWith <LoggingExtensions.log4net.Log4NetLog>(); this.Log().Info("开始更新缓存数据"); //大盘 if (this.Category == "3" || this.Category == "-1") { this.Log().Info("开始大盘缓存数据"); var objList = objectService.FindAll(); foreach (var obj in objList) { this.Log().Info("更新:" + obj.name); UpdateCacheData(ObjectType.Object, obj.code); } this.Log().Info("结束大盘缓存数据"); } //个股 if (this.Category == "1" || this.Category == "-1") { this.Log().Info("开始更新个股数据"); //var stockList = stockService.FindAll(); IList <data.stockcategory> cateList1 = cateService.GetCategoryList("tencent").ToList(); int total = 0; foreach (var category in cateList1) { IList <data.stock> stockList = stockService.GetStockByCategory(category.code); foreach (var stock in stockList) { this.Log().Info("更新:" + stock.name); UpdateCacheData(ObjectType.Stock, stock.code); } this.Log().Info("结束更新个股数据"); } } //行业 if (this.Category == "2" || this.Category == "-1") { this.Log().Info("开始更新行业数据"); var cateList = cateService.FindAll(); foreach (var cate in cateList) { this.Log().Info("更新:" + cate.name); UpdateCacheData(ObjectType.Category, cate.code); } this.Log().Info("结束更新行业数据"); } this.Log().Info("更新缓存数据结束!"); }
public void Send(IMessageSender sender) { this.Log().Info("开始计算个股形态"); DateTime StartDate0 = stockService.GetLatestDate(ObjectType.Stock, "0601988"); DateTime StartDate1 = stockService.GetLatestDate(ObjectType.Stock, "0601318"); var StartDate = StartDate0.CompareTo(StartDate1) >= 0 ? StartDate0 : StartDate1; IList <stockcategory> cateList = cateService.FindAll(); TechCycle[] cycleList = new TechCycle[] { TechCycle.day, TechCycle.week, TechCycle.month }; var log = this.Log(); foreach (var category in cateList) { if (StartDate.ToString("yyyyMMdd") == DateTime.Now.ToString("yyyyMMdd")) { log.Info(string.Format("导入今天日线数据,分类:{1}:从日期{0}", StartDate.ToString("yyyy-MM-dd"), category.name)); var task1 = new PriceUpdate { StartDate = StartDate, CateCode = category.code }; sender.Send(JsonConvert.SerializeObject(task1)); //ImportTodayPrice(stockList); } else { IList <data.stock> stockList = stockService.GetStockByCategory(category.code); foreach (var stock in stockList) { var task1 = new PriceUpdate { StartDate = StartDate, StockCode = stock.code }; sender.Send(JsonConvert.SerializeObject(task1)); //log.Info(string.Format("导入日线开始,股票:{1}:从日期{0}", StartDate.ToString("yyyy-MM-dd"), stock.name)); //ImportDay(stock, StartDate); //log.Info(string.Format("导入周线开始,股票:{1}:从日期{0}", StartDate.ToString("yyyy-MM-dd"), stock.name)); //ImportWeek(stock, StartDate); //log.Info(string.Format("导入月线开始,股票:{1}:从日期{0}", StartDate.ToString("yyyy-MM-dd"), stock.name)); //ImportMonth(stock, StartDate); //log.Info(string.Format("导入结束,股票:{1}:从日期{0}", StartDate.ToString("yyyy-MM-dd"), stock.name)); } } } }
private void ComputeCategoryState() { IList <stockcategory> cateList = cateService.FindAll(); this.Log().Info("开始计算行业形态"); //foreach (var category in cateList) //{ // this.Log().Info("计算行业:" + category.name); // Send(ObjectType.Category, category.code, TechCycle.Day); // Send(ObjectType.Category, category.code, TechCycle.Week); // Send(ObjectType.Category, category.code, TechCycle.Month); //} Parallel.ForEach <stockcategory>(cateList, (category) => { this.Log().Info("计算行业:" + category.name); //Send(ObjectType.Category, category.code, TechCycle.Day); //Send(ObjectType.Category, category.code, TechCycle.Week); //Send(ObjectType.Category, category.code, TechCycle.Month); this.TaskQueue.Enqueue(new IndexTask { type = ObjectType.Category, code = category.code, cycle = TechCycle.day }); this.TaskQueue.Enqueue(new IndexTask { type = ObjectType.Category, code = category.code, cycle = TechCycle.week }); this.TaskQueue.Enqueue(new IndexTask { type = ObjectType.Category, code = category.code, cycle = TechCycle.month }); }); }