18 using System.Collections.Generic;
45 public static ScheduledEvent EveryDayAt(
string name, IEnumerable<DateTime> dates, TimeSpan timeOfDay, Action<string, DateTime> callback, DateTime? currentUtcTime =
null)
47 var eventTimes = dates.Select(x => x.Date + timeOfDay);
48 if (currentUtcTime.HasValue)
50 eventTimes = eventTimes.Where(x => x < currentUtcTime.Value);
65 [Obsolete(
"This method is deprecated. It will generate ScheduledEvents for the deprecated IAlgorithm.OnEndOfDay()")]
70 throw new ArgumentException(
"Delta must be less than a day", nameof(endOfDayDelta));
74 var eodEventTime =
Time.
OneDay.Subtract(endOfDayDelta);
81 let eventTime = date + eodEventTime
83 let eventUtcTime = eventTime.ConvertToUtc(algorithm.
TimeZone)
85 where !currentUtcTime.HasValue || eventUtcTime > currentUtcTime.Value
89 algorithm.
Debug(
"Usage of QCAlgorithm.OnEndOfDay() without a symbol will be deprecated August 2021. Always use a symbol when overriding this method: OnEndOfDay(symbol)");
99 resultHandler.
RuntimeError($
"Runtime error in {name} event: {err.Message}", err.StackTrace);
100 Log.
Error(err, $
"ScheduledEvent.{name}:");
120 throw new ArgumentException(
"Delta must be less than a day", nameof(endOfDayDelta));
132 let marketClose = isMarketAlwaysOpen ?
135 let eventTime = isMarketAlwaysOpen ? marketClose : marketClose.Subtract(endOfDayDelta)
139 where !currentUtcTime.HasValue || eventUtcTime > currentUtcTime
146 algorithm.OnEndOfDay(security.Symbol);
148 catch (Exception err)
150 resultHandler.
RuntimeError($
"Runtime error in {name} event: {err.Message}", err.StackTrace);
151 Log.
Error(err, $
"ScheduledEvent.{name}:");
164 return $
"{scope}.{name}";