public ResizeableArray <TradeInfoItem> DownloadTradeHistory(TickerInputInfo info, DateTime time) { CachedTradeHistory savedData = new CachedTradeHistory() { Exchange = info.Exchange, TickerName = info.TickerName, StartDate = info.StartDate, EndDate = info.EndDate, BaseCurrency = info.Ticker.BaseCurrency, MarketCurrency = info.Ticker.MarketCurrency }; CachedTradeHistory cachedData = CachedTradeHistory.FromFile(CachedTradeHistory.Directory + "\\" + ((ISupportSerialization)savedData).FileName); info.CheckUpdateTime(); if (cachedData != null) { if (info.StartDate != DateTime.MinValue && info.StartDate == cachedData.Items[0].Time.Date && info.EndDate.AddDays(-1) <= cachedData.Items.Last().Time.Date) { return(cachedData.Items); } } DateTime start = info.StartDate.Date; int intervalInSeconds = info.KlineIntervalMin * 60; DateTime origin = start; DateTime end = info.EndDate.Date; ResizeableArray <TradeInfoItem> res = new ResizeableArray <TradeInfoItem>(); List <ResizeableArray <TradeInfoItem> > tmpList = new List <ResizeableArray <TradeInfoItem> >(); DownloadProgress = 0.0; DownloadText = "Donwloading Trade History Data for " + info.Exchange + ":" + info.TickerName; while (end > start) { ResizeableArray <TradeInfoItem> data = info.Ticker.Exchange.GetTrades(info.Ticker, start, end); if (data == null || data.Count == 0) { break; } tmpList.Add(data); DownloadProgress = 100 - (100 * (data.Last().Time - origin).TotalMinutes / (DateTime.UtcNow - origin).TotalMinutes); var args = RaiseDownloadProgressChanged(); if (args.Cancel) { return(null); } Thread.Sleep(300); end = data.Last().Time.AddMilliseconds(-1); } for (int i = tmpList.Count - 1; i >= 0; i--) { res.AddRangeReversed(tmpList[i]); } cachedData = savedData; cachedData.Items = res; cachedData.Save(); for (int i = 0; i < res.Count - 1; i++) { if (res[i].Time > res[i + 1].Time) { throw new Exception("TradeHistory Timing Error!"); } } return(res); }