Exemplo n.º 1
0
        public static HistoricalData ParseCsv(string filePath, string Ticker, string Name, HistoricalDataType DataType)
        {
            HistoricalData result = new HistoricalData();

            result.Ticker = Ticker;
            result.Name = Name;
            result.Stocks = new List<Stock>();

            using (StreamReader reader = new StreamReader(File.OpenRead(filePath)))
            {
                // skip first line which is date,open,high,low,close,volumn,adj close
                reader.ReadLine();
                string line;

                while ((line = reader.ReadLine()) != null)
                {
                    Stock price = Stock.ParsePrice(line, Ticker, Name);
                    result.Stocks.Add(price);
                }

                // filter according to daily, weekly or monthly
                result.ProcessPrices(result.Stocks, DataType);

                result.Stocks.Reverse();

            }

            return result;
        }