/***************************************************************************** * FUNCTION: ReadDataFile * Description: * Parameters: *****************************************************************************/ public Boolean ReadDataFile() { Boolean success = false; List <String[]> rawData = null; int index1, index2; string linkStr; if (dataFileName != "") { //parse the CSV into a list of string arrays rawData = CSVParser.CSVtoListArray(dataFileName, MAX_DATA_SIZE); linkStr = rawData[0][0]; if (linkStr != null && linkStr.Contains("http")) { this.liveDataAddress = linkStr; } //array index of each column of data //Indexes hardcoded based on ICom tables //historical data - Dates hist_data_in = rawData.Select(arr => arr[0]).ToList(); hist_dates = hist_data_in.Skip(DATA_FILE_HEADER_ROWS).Select(date => DateTime.Parse(date)).ToList(); hist_dates.Reverse(); //historical data - Closing Price hist_data_in = rawData.Select(arr => arr[1]).ToList(); hist_price = hist_data_in.Skip(DATA_FILE_HEADER_ROWS).Select(dbl => Helpers.CustomParseDouble(dbl)).ToList(); hist_price.Reverse(); //historical data - Opening Price hist_data_in = rawData.Select(arr => arr[2]).ToList(); hist_price_opens = hist_data_in.Skip(DATA_FILE_HEADER_ROWS).Select(dbl => Helpers.CustomParseDouble(dbl)).ToList(); hist_price_opens.Reverse(); //historical data - High hist_data_in = rawData.Select(arr => arr[3]).ToList(); hist_price_highs = hist_data_in.Skip(DATA_FILE_HEADER_ROWS).Select(dbl => Helpers.CustomParseDouble(dbl)).ToList(); hist_price_highs.Reverse(); //historical data - Low hist_data_in = rawData.Select(arr => arr[4]).ToList(); hist_price_lows = hist_data_in.Skip(DATA_FILE_HEADER_ROWS).Select(dbl => Helpers.CustomParseDouble(dbl)).ToList(); hist_price_lows.Reverse(); //historical data - Volume hist_data_in = rawData.Select(arr => arr[5]).ToList(); hist_volumes = hist_data_in.Skip(DATA_FILE_HEADER_ROWS).Select(dbl => Helpers.CustomParseDouble(dbl)).ToList(); hist_volumes.Reverse(); //historical data - percent change hist_data_in = rawData.Select(arr => arr[6]).ToList(); hist_daily_change = hist_data_in.Skip(DATA_FILE_HEADER_ROWS).Select(dbl => Math.Round(double.Parse(dbl.Replace("%", "")), 8)).ToList(); hist_daily_change.Reverse(); index1 = dataFileName.LastIndexOf("\\") + 1; index2 = dataFileName.LastIndexOf(".csv"); if (index1 > 0 && index2 > 0) { Name = dataFileName.Substring(index1, index2 - index1); } //IMPORTANT: ValidateHistoricalData() must be called before updateHistPublicProperties() to ensure the private // "hist_" data lists are finalized with any duplicate values removed. if (ValidateHistoricalData()) { this.ContainsHistData = true; } GetProfile(); updateHistPublicProperties(); //Compute technical indicators CalculatePctChange(); CalculateAvgPrice(); CalculateVolatility(); ComputeTrend(); ComputeTechnicalIndicators(); //set return status successful success = true; } return(success); }