/// <summary> /// Populate the day-interval barlist of this instance from a URL, where the results are returned as a CSV file. URL should accept requests in the form of http://url/get.py?sym=IBM /// </summary> /// <param name="url">The URL.</param> /// <returns></returns> private bool DayFromURL(string url) { if (Symbol == "") { return(false); } System.Net.WebClient wc = new System.Net.WebClient(); string res = ""; try { res = wc.DownloadString(url + Symbol); } catch (System.Net.WebException) { return(false); } string[] line = res.Split(Environment.NewLine.ToCharArray()); for (int i = line.Length - 1; i > 0; i--) { Bar mybar = null; if (line[i] != "") { mybar = Bar.FromCSV(line[i]); } if (mybar != null) { daylist.Add(mybar); } } return(true); }
/// <summary> /// Create a barlist from a succession of bar records provided as comma-delimited OHLC+volume data. /// </summary> /// <param name="symbol">The symbol.</param> /// <param name="file">The file containing the CSV records.</param> /// <returns></returns> public static BarList FromCSV(string symbol, string file) { BarList b = new BarList(BarInterval.Day, symbol); string[] line = file.Split(Environment.NewLine.ToCharArray()); for (int i = line.Length - 1; i > 0; i--) { Bar mybar = null; if (line[i] != "") { mybar = Bar.FromCSV(line[i]); } if (mybar != null) { b.daylist.Add(mybar); } } return(b); }