/// <summary> /// take ticks data on instrument for period /// взять тиковые данные по инструменту за период /// </summary> public List <Trade> GetTickDataToSecurity(Security security, DateTime startTime, DateTime endTime, DateTime lastDate) { string markerDateTime = ""; List <Trade> trades = new List <Trade>(); DateTime startOver = startTime; if (endTime > DateTime.Now - new TimeSpan(0, 0, 1, 0)) { endTime = DateTime.Now - new TimeSpan(0, 0, 1, 0); } while (true) { if (startOver >= endTime) { break; } List <Trade> newTrades = _client.GetTickHistoryToSecurity(security.Name, startOver); if (newTrades != null && newTrades.Count != 0) { trades.AddRange(newTrades); } else { break; } startOver = trades[trades.Count - 1].Time.AddMilliseconds(1); if (markerDateTime != startOver.ToShortDateString()) { markerDateTime = startOver.ToShortDateString(); SendLogMessage(security.Name + " Binance Futures start loading: " + markerDateTime, LogMessageType.System); } Thread.Sleep(300); } if (trades.Count == 0) { return(null); } while (trades.Last().Time >= endTime) { trades.Remove(trades.Last()); } return(trades); }
/// <summary> /// take ticks data on instrument for period /// взять тиковые данные по инструменту за период /// </summary> public List <Trade> GetTickDataToSecurity(Security security, DateTime startTime, DateTime endTime, DateTime lastDate) { List <Trade> lastTrades = new List <Trade>(); string tradeId = ""; DateTime lastTradeTime = DateTime.MaxValue; while (lastTradeTime > startTime) { lastDate = TimeZoneInfo.ConvertTimeToUtc(lastDate); List <Trade> trades = _client.GetTickHistoryToSecurity(security, tradeId); if (trades == null || trades.Count == 0) { lastTradeTime = lastDate.AddSeconds(-1); Thread.Sleep(2000); continue; } DateTime uniTime = trades[trades.Count - 1].Time.ToUniversalTime(); lastTradeTime = trades[0].Time; for (int i2 = 0; i2 < trades.Count; i2++) { lastTrades.Insert(i2, trades[i2]); } tradeId = (Convert.ToInt32(trades[0].Id) - 1000).ToString(); Thread.Sleep(100); } return(lastTrades); }