protected override void ExecuteTask(VcssTaskModel vcssTask) { DateTime marketDate = DateTime.UtcNow.AddHours(vcssTask.VcssTaskInfo.Market.utc_offset).Date; Dictionary <string, int> symbols = StockService.GetStocks().Where(s => s.market_id == 1 && s.type_id == 4 && s.active).ToDictionary(s => s.symbol, s => s.Id); List <jsonmdlBOLSARIndex> data = JsonConvert.DeserializeObject <List <jsonmdlBOLSARIndex> >(vcssTask.data).Where(x => symbols.ContainsKey(x.Symbol)).ToList(); //INTRADIARY DATA List <IRealTimeQuote> realTimeQuotes = data.Select(rt => new RealTimeQuoteBOLSAR() { ask = 0, ask_size = 0, bid = 0, bid_size = 0, change = rt.Tendencia, change_percent = rt.Variacion, datetime = this.GetIntradiaryDateTime(marketDate, rt.strHora), last_trade_date = DateTime.Now, last_trade_price = rt.Ultimo, last_trade_size = 0, last_trade_time = "", opening = rt.Ultimo, prev_closing = rt.Apertura, stock_id = symbols[rt.Symbol] }).ToList <IRealTimeQuote>(); //HISTORICAL DATA List <IHistoricalQuote> historicalQuotes = data.Select(h => new HistoricalQuoteBOLSAR() { adj_close = 0, closing = h.Ultimo, date_round = marketDate, maximun = h.Maximo_Valor, minimun = h.Minimo_Valor, opening = h.Apertura, stock_id = symbols[h.Symbol], volume = 0 }).ToList <IHistoricalQuote>(); QuotesService.SaveRealTimeQuote(realTimeQuotes); QuotesService.SaveHistoricalQuote(historicalQuotes); }
protected override void ExecuteTask(VcssTaskModel vcssTask) { DateTime marketDate = DateTime.UtcNow.AddHours(vcssTask.VcssTaskInfo.Market.utc_offset).Date; Dictionary <string, int> symbols = StockService.GetStocks().Where(s => s.market_id == 2 && s.active).ToDictionary(s => s.symbol + ".US", s => s.Id); IEnumerable <jsonmdlEODRealTime> data = JsonConvert.DeserializeObject <List <jsonmdlEODRealTime> >(vcssTask.data).Where(rt => symbols.ContainsKey(rt.Code)); //INTRADIARY DATA List <IRealTimeQuote> realTimeQuotes = data.Select(rt => new RealTimeQuoteEOD() { ask = 0, ask_size = 0, bid = 0, bid_size = 0, change = 0, change_percent = rt.Change, datetime = this.GetIntradiaryDateTime(vcssTask.VcssTaskInfo.Market.utc_offset, rt.Timestamp), last_trade_date = DateTime.Now, last_trade_price = rt.Close, last_trade_size = 0, last_trade_time = "", opening = rt.Close, prev_closing = rt.PreviousClose, stock_id = symbols[rt.Code] }).ToList <IRealTimeQuote>(); //HISTORICAL DATA List <IHistoricalQuote> historicalQuotes = data.Select(h => new HistoricalQuoteEOD() { adj_close = 0, closing = h.Close, date_round = marketDate, maximun = h.High, minimun = h.Low, opening = h.Open, stock_id = symbols[h.Code], volume = h.Volume }).ToList <IHistoricalQuote>(); QuotesService.SaveRealTimeQuote(realTimeQuotes); QuotesService.SaveHistoricalQuote(historicalQuotes); }