public void Execute(IJobExecutionContext context) { IList <data.StockCategory> cateList = cateService.GetCategoryList("tencent"); foreach (var category in cateList) { IList <data.Stock> stockList = stockService.GetStockByCategory(category.code); for (int i = 0; i < stockList.Count; i += batchNum) { IList <data.StockInfo> spList = sync.GetPrice(stockList.Skip(i).Take(batchNum).ToList()); IList <data.PriceInfo> spiList = spList.Select(p => new data.PriceInfo { code = p.stock_code, date = p.date, high = p.high, low = p.low, open = p.open, percent = p.percent, price = p.price, updown = p.updown, volume = p.volume, yestclose = p.yestclose }).ToList(); stockService.AddPriceByDay(spiList); stockService.AddPriceByWeek(spiList); stockService.AddPriceByMonth(spiList); } } }
private bool ImportMonth(data.stock stock) { try { IList <data.PriceInfo> spmonth = sync.GetPriceByMonth(stock); var list = spmonth.OrderBy(p => p.date).ToList(); for (int i = 1; i < list.Count(); i++) { list[i].yestclose = list[i - 1].price; list[i].updown = list[i].price - list[i].yestclose; list[i].percent = list[i].updown / list[i].yestclose; } stockService.AddPriceByMonth <data.data_stock_month_latest>(spmonth, false); this.Log().Info("月线:" + stock.code + stock.name); return(true); } catch (Exception ex) { stockService.AddPriceSyncLog(new data.pricesynclog { batch = this.batch.ToString(), stock_code = stock.code, description = ex.GetBaseException().Message, creatime = DateTime.Now, type = "month" }); return(false); } }
private bool ImportMonth(string stockCode, DateTime startDate) { IList <data.PriceInfo> spmonth = sync.GetPriceByMonth(stockCode); var list = spmonth.Where(p => p.date >= startDate.AddDays(-30)).OrderBy(p => p.date).ToList(); for (int i = 1; i < list.Count(); i++) { list[i].yestclose = list[i - 1].price; list[i].updown = list[i].price - list[i].yestclose; list[i].percent = list[i].updown / list[i].yestclose; } if (list.Count > 0) { list.RemoveAt(0); } stockService.AddPriceByMonth <data.data_stock_month_latest>(list); this.Log().Info("月线:" + stockCode); return(true); }
private bool ImportMonth(data.stock stock) { try { IList <data.PriceInfo> spmonth = sync.GetPriceByMonth(stock); var list = spmonth.OrderBy(p => p.date).ToList(); for (int i = 1; i < list.Count(); i++) { list[i].yestclose = list[i - 1].price; list[i].updown = list[i].price - list[i].yestclose; list[i].percent = list[i].updown / list[i].yestclose; } stockService.AddPriceByMonth <data.data_stock_month_latest>(spmonth, false); this.Log().Info("月线:" + stock.code + stock.name); return(true); } catch (Exception ex) { return(false); } }