/// <summary> /// Downloads daily historical stock data. /// </summary> public string HistoricalDataDownload(string stock, string startDate, WebClient web, WebURIs uRIs, DateTime date, PeregrineOperation peregrine, Transactions transactions) { string endDate = date.ToShortDateString(); string stockData = web.DownloadString(uRIs.WSJHistorical(stock, startDate, endDate)); // method call to retrieve the data return(stockData); }
/// <summary> /// The Trading Days method allows the program to validate if the file being downloaded holds the correct amount of data. I am using five of the largest /// stocks which are heavily tracked. It is unlikely that there will not be historical data on these five stocks, making them a good bench mark. /// </summary> /// <param name="numberDays"></param> /// <returns></returns> private int tradingDays(string startDate, WebClient web, WebURIs uRIs, DateTime date) { List <string> FAANG = new List <string> { "FB", "AAPL", "AMZN", "NFLX", "GOOGL" }; // Top Tech stocks: Facebook, Apple, Amazon, NetFlix, Google int count = 0; // count of the total trading days recorded for FAANG over the period. foreach (var item in FAANG) { // (website location (stock requested, startdate, enddate) splitting by the return symbol > places it into an array > counts the array elements int rows = web.DownloadString(uRIs.WSJHistorical(item, startDate, date.ToShortDateString())).Split('\n').ToArray().Count(); count += rows; // count = count(current) + rows } int tradingDays = count / 5; return(tradingDays); }