Beispiel #1
0
        public static StockPrices ReadStock(string symbol, string dataColumnName, TimeSeries dayOffsets)
        {
            var prices = new StockPrices(dayOffsets.Count);
            string filePath = DataAccess.GetInstance().GetFilePath(symbol);
            using (var csv = new CsvReader2(filePath))
            {
                while (csv.Read())
                {
                    var date = csv.GetDateTime("Date");
                    int offset = dayOffsets.GetOffsetDaysFromStart(date);
                    if (offset < 0)
                        continue;

                    var price = csv.GetFloat(dataColumnName);
                    prices.Set(offset, price);
                }
            }
            return prices;
        }