public override bool OpenFeed() { parser = new TextFieldParser(dataFilePath); parser.TextFieldType = FieldType.Delimited; parser.SetDelimiters(","); parser.CommentTokens = new string[] { "#" }; parser.ReadLine(); /* skip the headers line */ SimpleConsoleLog.LogMessage("Openning the file " + dataFilePath + " as market data file", SimpleConsoleLog.LogLevel.Info); return(true); }
static void ReadDataFunc(DataFeed Feed, ConcurrentQueue <StockData> DataQueue) { Feed.OpenFeed(); while (Feed.HasData().HasValue&& Feed.HasData().Value) { are.WaitOne(); StockData data = null; if (!Feed.ConsumeData(ref data)) { SimpleConsoleLog.LogMessage("Done reading data from feed", SimpleConsoleLog.LogLevel.Info); break; } DataQueue.Enqueue(data); System.Threading.Thread.Sleep(DelayBetweenStockPrintsMiliSecond); } }
public override bool ConsumeData(ref StockData Data) { if (parser == null || parser.EndOfData) { return(false); } var fileData = parser.ReadFields(); try { Data = new StockData(fileData[0], fileData[1], fileData[2], Double.Parse(fileData[3]), Double.Parse(fileData[4]), Double.Parse(fileData[5]), Double.Parse(fileData[6]), Double.Parse(fileData[7]), Double.Parse(fileData[8])); } catch (Exception ex) { if (ex is ArgumentNullException || ex is FormatException) { SimpleConsoleLog.LogMessage("error in input data at line " + parser.ErrorLineNumber, SimpleConsoleLog.LogLevel.Error); } } return(true); }