public Market(string name, IApiDriver api) { Name = name; Interval = TradeMan.Interval; //From = DateTime.Now.Date - TradeMan.MinInterval; CourseData = new CourseItem[0]; _api = api; }
/// <summary> /// Загружаем до текущей даты. последний элемент с неполными данными не добавляем /// true если добавлен элемент /// </summary> /// <returns></returns> public bool LoadHistory(DatePeriod period = null) { var course = new Course(_api); if (period == null) { var to = new DateTime(DateTime.Now.Ticks / Interval.Ticks * Interval.Ticks); if (CourseData.Length == 0) // нет истории { period = new DatePeriod(From, to); } else { period = new DatePeriod(To + Interval, to); } } if (DbgSett.Options.Contains(DbgSett.DbgOption.ShowLoadingHistory)) { Log.CreateLog("LoadHistory", period.ToString()); } var newData = course.GetHistory(Name, period, Interval).ToArray(); int lastNotNul = -1; for (int i = newData.Length - 1; i > -1; i--) { if (newData[i].course != 0) { lastNotNul = i; break; } } if (lastNotNul < 1) { return(false); } var joined = new CourseItem[CourseData.Length + lastNotNul]; Array.Copy(CourseData, joined, CourseData.Length); Array.Copy(newData, 0, joined, CourseData.Length, lastNotNul); CourseData = joined; return(true); }