Esempio n. 1
0
        private StockDataset CreateStockDataset(string[] csvLine, Dictionary <string, int> headersPosition)
        {
            try
            {
                StockDataset dataset = new StockDataset
                {
                    Close = GetCsvDecimal(csvLine, headersPosition, extendedHeaders["Close"]),
                    Last  = GetCsvDecimal(csvLine, headersPosition, extendedHeaders["Last"]),
                    Low   = GetCsvDecimal(csvLine, headersPosition, extendedHeaders["Low"]),
                    Open  = GetCsvDecimal(csvLine, headersPosition, extendedHeaders["Open"]),
                    High  = GetCsvDecimal(csvLine, headersPosition, extendedHeaders["High"]),
                    TotalTradeQuantity = GetCsvDecimal(csvLine, headersPosition, extendedHeaders["TotalTradeQuantity"]),
                    Turnover           = GetCsvDecimal(csvLine, headersPosition, extendedHeaders["Turnover"]),
                    Date = GetCsvDate(csvLine, headersPosition, extendedHeaders["Date"])
                };

                return(dataset);
            }
            catch (IndexOutOfRangeException ex)
            {
                Console.WriteLine("CreateDataset Exception: " + ex.Message);

                return(null);
            }
            catch (FormatException ex)
            {
                Console.WriteLine("CreateDataset Exception: " + ex.Message);

                return(null);
            }
        }
Esempio n. 2
0
        private IEnumerable <StockDataset> CreateStockDatasetRange(IEnumerable <string[]> csvContent, Dictionary <string, int> headersPosition)
        {
            try
            {
                List <StockDataset> datasets = new List <StockDataset>(csvContent.Count());

                foreach (string[] csvLine in csvContent)
                {
                    StockDataset dataset = CreateStockDataset(csvLine, headersPosition);

                    if (dataset != null)
                    {
                        datasets.Add(dataset);
                    }
                }

                return(datasets);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }