public List <Models.StockInfo> Get(string symbol, string start) { string Symbol = symbol; DateTime startDate = Convert.ToDateTime(start);//Convert.ToDateTime("11 / 30 / 2015 12:00:00 AM"); DateTime endDate = DateTime.Today; string csvData; using (System.Net.WebClient web = new WebClient()) { string downloadString = "https://stooq.com/q/d/l/?s=" + Symbol + ".us&c=0" + "&d1=" + startDate.ToString("yyyyMMdd") + "&d2=" + endDate.ToString("yyyyMMdd") + "&i=d"; csvData = web.DownloadString(downloadString); Models.StockList stocks = Models.YahooFinance.Parse(csvData, Symbol, startDate, endDate); return(stocks.dataList); } }
public List <Models.StockInfo> Get(string symbol) { string Symbol = symbol; DateTime now = DateTime.Today; DateTime startDate = new DateTime((now.Year - 1), now.Month, now.Day, 0, 0, 0); DateTime endDate = DateTime.Today; string csvData; using (System.Net.WebClient web = new WebClient()) { string downloadString = "https://stooq.com/q/d/l/?s=" + Symbol + ".us&c=0" + "&d1=" + startDate.ToString("yyyyMMdd") + "&d2=" + endDate.ToString("yyyyMMdd") + "&i=d"; csvData = web.DownloadString(downloadString); Models.StockList stocks = Models.YahooFinance.Parse(csvData, Symbol, startDate, endDate); return(stocks.dataList); } }
public static byUser Parse(List <tweetsByUserSolo> tList, DateTime start, string symbol) { byUser final = new byUser(); List <tweetsByUser> finalList = new List <tweetsByUser>(); Models.StockList stocks = new Models.StockList(); string Symbol = symbol; DateTime startDate = start; DateTime endDate = DateTime.Today; string csvData; using (System.Net.WebClient web = new WebClient()) { string downloadString = "https://stooq.com/q/d/l/?s=" + Symbol + ".us&c=0" + "&d1=" + startDate.ToString("yyyyMMdd") + "&d2=" + endDate.ToString("yyyyMMdd") + "&i=d"; csvData = web.DownloadString(downloadString); stocks = Models.YahooFinance.Parse(csvData, Symbol, startDate, endDate); } DateTime cur = start; while (cur <= DateTime.Now) { tweetsByUser temp = new tweetsByUser(); temp.date = cur; foreach (Models.StockInfo s in stocks.dataList) { if (s.date == cur) { temp.price = s.price; } } foreach (tweetsByUserSolo t in tList) { if (t.date == cur) { temp.count = t.count; } } cur = cur.AddDays(1); finalList.Add(temp); } for (int i = 0; i < finalList.Count; i++) { if (finalList[i].price == 0 && i > 0) { finalList[i].price = finalList[i - 1].price; } else if (finalList[i].price == 0 && i == 0) { finalList.RemoveAt(i); i--; } } final.userTweetList = finalList; return(final); }