public StockDataPoint RandomRemoveFromSet() { Random r = new Random(); int indexToRemove = r.Next(0, sizeLimit); StockDataPoint ret = dataSet[indexToRemove]; dataSet.RemoveAt(indexToRemove); sizeLimit--; return(ret); }
public static List <StockDataPoint> ReadStockFile(string path) { List <StockDataPoint> dataPoints = new List <StockDataPoint>(); TextFieldParser csvParser = new TextFieldParser(path); csvParser.TextFieldType = FieldType.Delimited; csvParser.SetDelimiters(","); csvParser.ReadFields(); // Skip first line. while (!csvParser.EndOfData) { string[] p = csvParser.ReadFields(); float open = float.Parse(p[1]); float high = float.Parse(p[2]); float low = float.Parse(p[3]); float close = float.Parse(p[4]); float volume = float.Parse(p[5]); StockDataPoint dataPoint = new StockDataPoint(open, high, low, close, volume); dataPoints.Add(dataPoint); } csvParser.Close(); return(dataPoints); }