/// <summary>
 /// Initializes a new instance of the <see cref="ScheduledUniverseSelectionModel"/> class using the algorithm's time zone
 /// </summary>
 /// <param name="dateRule">Date rule defines what days the universe selection function will be invoked</param>
 /// <param name="timeRule">Time rule defines what times on each day selected by date rule the universe selection function will be invoked</param>
 /// <param name="selector">Selector function accepting the date time firing time and returning the universe selected symbols</param>
 /// <param name="settings">Universe settings for subscriptions added via this universe, null will default to algorithm's universe settings</param>
 public ScheduledUniverseSelectionModel(IDateRule dateRule, ITimeRule timeRule, Func <DateTime, IEnumerable <Symbol> > selector, UniverseSettings settings = null)
 {
     _dateRule = dateRule;
     _timeRule = timeRule;
     _selector = selector;
     _settings = settings;
 }
        /// <summary>
        /// Schedules the callback to run using the specified date and time rules
        /// </summary>
        /// <param name="name">The event's unique name</param>
        /// <param name="dateRule">Specifies what dates the event should run</param>
        /// <param name="timeRule">Specifies the times on those dates the event should run</param>
        /// <param name="callback">The callback to be invoked</param>
        public ScheduledEvent On(string name, IDateRule dateRule, ITimeRule timeRule, Action <string, DateTime> callback)
        {
            // back the date up to ensure we get all events, the event scheduler will skip past events that whose time has passed
            var dates          = dateRule.GetDates(_securities.UtcTime.Date.AddDays(-1), Time.EndOfTime);
            var eventTimes     = timeRule.CreateUtcEventTimes(dates);
            var scheduledEvent = new ScheduledEvent(name, eventTimes, callback);

            Add(scheduledEvent);

            var exampleTimes = eventTimes.Take(3)
                               .Select(x => x.ToString())
                               .ToArray();

            if (exampleTimes.Length > 0)
            {
                Log.Trace("Event Name \"{0}\", scheduled to run at {1} (UTC){2}",
                          name, string.Join(", ", exampleTimes),
                          exampleTimes.Length > 1? "..." : "");
            }
            else
            {
                Log.Trace("Event Name \"{0}\", scheduled to run, but no event times were selected", name);
            }

            return(scheduledEvent);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Schedules the callback to run using the specified date and time rules
 /// </summary>
 /// <param name="name">The event's unique name</param>
 /// <param name="dateRule">Specifies what dates the event should run</param>
 /// <param name="timeRule">Specifies the times on those dates the event should run</param>
 /// <param name="callback">The callback to be invoked</param>
 public void On(string name, IDateRule dateRule, ITimeRule timeRule, Action callback)
 {
     var dates = dateRule.GetDates(_securities.UtcTime, Time.EndOfTime);
     var eventTimes = timeRule.CreateUtcEventTimes(dates);
     var scheduledEvent = new ScheduledEvent(name, eventTimes, (s, time) => callback());
     _eventSchedule.Add(scheduledEvent);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ScheduledUniverse"/> class
 /// </summary>
 /// <param name="timeZone">The time zone the date/time rules are in</param>
 /// <param name="dateRule">Date rule defines what days the universe selection function will be invoked</param>
 /// <param name="timeRule">Time rule defines what times on each day selected by date rule the universe selection function will be invoked</param>
 /// <param name="selector">Selector function accepting the date time firing time and returning the universe selected symbols</param>
 /// <param name="settings">Universe settings for subscriptions added via this universe, null will default to algorithm's universe settings</param>
 /// <param name="securityInitializer">Security initializer for new securities created via this universe, null will default to algorithm's security initializer</param>
 public ScheduledUniverse(DateTimeZone timeZone, IDateRule dateRule, ITimeRule timeRule, Func <DateTime, IEnumerable <Symbol> > selector, UniverseSettings settings = null, ISecurityInitializer securityInitializer = null)
     : base(CreateConfiguration(timeZone, dateRule, timeRule), securityInitializer)
 {
     _dateRule        = dateRule;
     _timeRule        = timeRule;
     _selector        = selector;
     UniverseSettings = settings;
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ScheduledUniverseSelectionModel"/> class using the algorithm's time zone
 /// </summary>
 /// <param name="dateRule">Date rule defines what days the universe selection function will be invoked</param>
 /// <param name="timeRule">Time rule defines what times on each day selected by date rule the universe selection function will be invoked</param>
 /// <param name="selector">Selector function accepting the date time firing time and returning the universe selected symbols</param>
 /// <param name="settings">Universe settings for subscriptions added via this universe, null will default to algorithm's universe settings</param>
 /// <param name="initializer">Security initializer for new securities created via this universe, null will default to algorithm's security initializer</param>
 public ScheduledUniverseSelectionModel(IDateRule dateRule, ITimeRule timeRule, Func <DateTime, IEnumerable <Symbol> > selector, UniverseSettings settings = null, ISecurityInitializer initializer = null)
 {
     _dateRule    = dateRule;
     _timeRule    = timeRule;
     _selector    = selector;
     _settings    = settings;
     _initializer = initializer;
 }
Ejemplo n.º 6
0
        public ScheduledEvent On(string name, IDateRule dateRule, ITimeRule timeRule, Action <string, DateTime> callback)
        {
            var dates          = dateRule.GetDates(_securities.UtcTime.Date.AddDays(-1), Time.EndOfTime);
            var eventTimes     = timeRule.CreateUtcEventTimes(dates);
            var scheduledEvent = new ScheduledEvent(name, eventTimes, callback);

            Add(scheduledEvent);
            return(scheduledEvent);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Schedules the callback to run using the specified date and time rules
        /// </summary>
        /// <param name="name">The event's unique name</param>
        /// <param name="dateRule">Specifies what dates the event should run</param>
        /// <param name="timeRule">Specifies the times on those dates the event should run</param>
        /// <param name="callback">The callback to be invoked</param>
        public ScheduledEvent On(string name, IDateRule dateRule, ITimeRule timeRule, Action <string, DateTime> callback)
        {
            // back the date up to ensure we get all events, the event scheduler will skip past events that whose time has passed
            var dates          = dateRule.GetDates(_securities.UtcTime.Date.AddDays(-1), Time.EndOfTime);
            var eventTimes     = timeRule.CreateUtcEventTimes(dates);
            var scheduledEvent = new ScheduledEvent(name, eventTimes, callback);

            Add(scheduledEvent);
            return(scheduledEvent);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ScheduledUniverseSelectionModel"/> class
        /// </summary>
        /// <param name="timeZone">The time zone the date/time rules are in</param>
        /// <param name="dateRule">Date rule defines what days the universe selection function will be invoked</param>
        /// <param name="timeRule">Time rule defines what times on each day selected by date rule the universe selection function will be invoked</param>
        /// <param name="selector">Selector function accepting the date time firing time and returning the universe selected symbols</param>
        /// <param name="settings">Universe settings for subscriptions added via this universe, null will default to algorithm's universe settings</param>
        public ScheduledUniverseSelectionModel(DateTimeZone timeZone, IDateRule dateRule, ITimeRule timeRule, PyObject selector, UniverseSettings settings = null)
        {
            Func <DateTime, object> func;

            selector.TryConvertToDelegate(out func);
            _timeZone = timeZone;
            _dateRule = dateRule;
            _timeRule = timeRule;
            _selector = func.ConvertToUniverseSelectionSymbolDelegate();
            _settings = settings;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ScheduledUniverse"/> class
        /// </summary>
        /// <param name="timeZone">The time zone the date/time rules are in</param>
        /// <param name="dateRule">Date rule defines what days the universe selection function will be invoked</param>
        /// <param name="timeRule">Time rule defines what times on each day selected by date rule the universe selection function will be invoked</param>
        /// <param name="selector">Selector function accepting the date time firing time and returning the universe selected symbols</param>
        /// <param name="settings">Universe settings for subscriptions added via this universe, null will default to algorithm's universe settings</param>
        public ScheduledUniverse(DateTimeZone timeZone, IDateRule dateRule, ITimeRule timeRule, PyObject selector, UniverseSettings settings = null)
            : base(CreateConfiguration(timeZone, dateRule, timeRule))
        {
            Func <DateTime, object> func;

            selector.TryConvertToDelegate(out func);
            _dateRule        = dateRule;
            _timeRule        = timeRule;
            _selector        = func.ConvertToUniverseSelectionSymbolDelegate();
            UniverseSettings = settings;
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ScheduledUniverse"/> class
        /// </summary>
        /// <param name="timeZone">The time zone the date/time rules are in</param>
        /// <param name="dateRule">Date rule defines what days the universe selection function will be invoked</param>
        /// <param name="timeRule">Time rule defines what times on each day selected by date rule the universe selection function will be invoked</param>
        /// <param name="selector">Selector function accepting the date time firing time and returning the universe selected symbols</param>
        /// <param name="settings">Universe settings for subscriptions added via this universe, null will default to algorithm's universe settings</param>
        /// <param name="securityInitializer">Security initializer for new securities created via this universe, null will default to algorithm's security initializer</param>
        public ScheduledUniverse(DateTimeZone timeZone, IDateRule dateRule, ITimeRule timeRule, PyObject selector, UniverseSettings settings = null, ISecurityInitializer securityInitializer = null)
            : base(CreateConfiguration(timeZone, dateRule, timeRule))
        {
            Func <DateTime, Symbol[]> func;

            selector.TryConvertToDelegate(out func);
            _dateRule        = dateRule;
            _timeRule        = timeRule;
            _selector        = func;
            UniverseSettings = settings;
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ScheduledUniverseSelectionModel"/> class using the algorithm's time zone
        /// </summary>
        /// <param name="dateRule">Date rule defines what days the universe selection function will be invoked</param>
        /// <param name="timeRule">Time rule defines what times on each day selected by date rule the universe selection function will be invoked</param>
        /// <param name="selector">Selector function accepting the date time firing time and returning the universe selected symbols</param>
        /// <param name="settings">Universe settings for subscriptions added via this universe, null will default to algorithm's universe settings</param>
        /// <param name="initializer">Security initializer for new securities created via this universe, null will default to algorithm's security initializer</param>
        public ScheduledUniverseSelectionModel(IDateRule dateRule, ITimeRule timeRule, PyObject selector, UniverseSettings settings = null, ISecurityInitializer initializer = null)
        {
            Func <DateTime, Symbol[]> func;

            selector.TryConvertToDelegate(out func);
            _dateRule    = dateRule;
            _timeRule    = timeRule;
            _selector    = func;
            _settings    = settings;
            _initializer = initializer;
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Schedules the callback to run using the specified date and time rules
        /// </summary>
        /// <param name="name">The event's unique name</param>
        /// <param name="dateRule">Specifies what dates the event should run</param>
        /// <param name="timeRule">Specifies the times on those dates the event should run</param>
        /// <param name="callback">The callback to be invoked</param>
        public ScheduledEvent On(string name, IDateRule dateRule, ITimeRule timeRule, Action <string, DateTime> callback)
        {
            // back the date up to ensure we get all events, the event scheduler will skip past events that whose time has passed
            var dates          = GetDatesDeferred(dateRule, _securities);
            var eventTimes     = timeRule.CreateUtcEventTimes(dates);
            var scheduledEvent = new ScheduledEvent(name, eventTimes, callback);

            Add(scheduledEvent);

            Log.Trace($"Event Name \"{scheduledEvent.Name}\", scheduled to run.");
            return(scheduledEvent);
        }
Ejemplo n.º 13
0
        private FluentScheduledEventBuilder SetTimeRule(ITimeRule rule)
        {
            if (_timeRule == null)
            {
                _timeRule = rule;
                return(this);
            }
            var compositeTimeRule = _timeRule as CompositeTimeRule;

            if (compositeTimeRule != null)
            {
                var rules = compositeTimeRule.Rules;
                _timeRule = new CompositeTimeRule(rules.Concat(new[] { rule }));
                return(this);
            }
            _timeRule = new CompositeTimeRule(_timeRule, rule);
            return(this);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Schedules the callback to run using the specified date and time rules
        /// </summary>
        /// <param name="name">The event's unique name</param>
        /// <param name="dateRule">Specifies what dates the event should run</param>
        /// <param name="timeRule">Specifies the times on those dates the event should run</param>
        /// <param name="callback">The callback to be invoked</param>
        public ScheduledEvent On(string name, IDateRule dateRule, ITimeRule timeRule, Action <string, DateTime> callback)
        {
            // back the date up to ensure we get all events, the event scheduler will skip past events that whose time has passed
            var dates          = dateRule.GetDates(_securities.UtcTime.Date.AddDays(-1), Time.EndOfTime);
            var eventTimes     = timeRule.CreateUtcEventTimes(dates);
            var scheduledEvent = new ScheduledEvent(name, eventTimes, callback);

            Add(scheduledEvent);

            // ScheduledEvent constructor will prime the scheduled event
            if (scheduledEvent.NextEventUtcTime != DateTime.MaxValue)
            {
                Log.Trace($"Event Name \"{scheduledEvent.Name}\", scheduled to run at {scheduledEvent.NextEventUtcTime} (UTC)...");
            }
            else
            {
                Log.Error($"Event Name \"{scheduledEvent.Name}\", scheduled to run, but no event times were selected");
            }

            return(scheduledEvent);
        }
Ejemplo n.º 15
0
        private FluentScheduledEventBuilder SetTimeRule(ITimeRule rule)
        {
            // if it's not set, just set it
            if (_timeRule == null)
            {
                _timeRule = rule;
                return this;
            }

            // if it's already a composite, open it up and make a new composite
            // prevent nesting composites
            var compositeTimeRule = _timeRule as CompositeTimeRule;
            if (compositeTimeRule != null)
            {
                var rules = compositeTimeRule.Rules;
                _timeRule = new CompositeTimeRule(rules.Concat(new[] { rule }));
                return this;
            }

            // create a composite from the existing rule and the new rules
            _timeRule = new CompositeTimeRule(_timeRule, rule);
            return this;
        }
        private FluentScheduledEventBuilder SetTimeRule(ITimeRule rule)
        {
            // if it's not set, just set it
            if (_timeRule == null)
            {
                _timeRule = rule;
                return(this);
            }

            // if it's already a composite, open it up and make a new composite
            // prevent nesting composites
            var compositeTimeRule = _timeRule as CompositeTimeRule;

            if (compositeTimeRule != null)
            {
                var rules = compositeTimeRule.Rules;
                _timeRule = new CompositeTimeRule(rules.Concat(new[] { rule }));
                return(this);
            }

            // create a composite from the existing rule and the new rules
            _timeRule = new CompositeTimeRule(_timeRule, rule);
            return(this);
        }
Ejemplo n.º 17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ScheduledUniverse"/> class
 /// </summary>
 /// <param name="dateRule">Date rule defines what days the universe selection function will be invoked</param>
 /// <param name="timeRule">Time rule defines what times on each day selected by date rule the universe selection function will be invoked</param>
 /// <param name="selector">Selector function accepting the date time firing time and returning the universe selected symbols</param>
 /// <param name="settings">Universe settings for subscriptions added via this universe, null will default to algorithm's universe settings</param>
 /// <param name="securityInitializer">Security initializer for new securities created via this universe, null will default to algorithm's security initializer</param>
 public ScheduledUniverse(IDateRule dateRule, ITimeRule timeRule, PyObject selector, UniverseSettings settings = null, ISecurityInitializer securityInitializer = null)
     : this(TimeZones.NewYork, dateRule, timeRule, selector, settings, securityInitializer)
 {
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ScheduledUniverse"/> class
 /// </summary>
 /// <param name="dateRule">Date rule defines what days the universe selection function will be invoked</param>
 /// <param name="timeRule">Time rule defines what times on each day selected by date rule the universe selection function will be invoked</param>
 /// <param name="selector">Selector function accepting the date time firing time and returning the universe selected symbols</param>
 /// <param name="settings">Universe settings for subscriptions added via this universe, null will default to algorithm's universe settings</param>
 public ScheduledUniverse(IDateRule dateRule, ITimeRule timeRule, Func <DateTime, IEnumerable <Symbol> > selector, UniverseSettings settings = null)
     : this(TimeZones.NewYork, dateRule, timeRule, selector, settings)
 {
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ScheduledUniverse"/> class
 /// </summary>
 /// <param name="dateRule">Date rule defines what days the universe selection function will be invoked</param>
 /// <param name="timeRule">Time rule defines what times on each day selected by date rule the universe selection function will be invoked</param>
 /// <param name="selector">Selector function accepting the date time firing time and returning the universe selected symbols</param>
 /// <param name="settings">Universe settings for subscriptions added via this universe, null will default to algorithm's universe settings</param>
 public ScheduledUniverse(IDateRule dateRule, ITimeRule timeRule, PyObject selector, UniverseSettings settings = null)
     : this(TimeZones.NewYork, dateRule, timeRule, selector, settings)
 {
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Schedules the callback to run using the specified date and time rules
 /// </summary>
 /// <param name="dateRule">Specifies what dates the event should run</param>
 /// <param name="timeRule">Specifies the times on those dates the event should run</param>
 /// <param name="callback">The callback to be invoked</param>
 public void On(IDateRule dateRule, ITimeRule timeRule, Action callback)
 {
     var name = dateRule.Name + ": " + timeRule.Name;
     On(name, dateRule, timeRule, callback);
 }
Ejemplo n.º 21
0
        private static SubscriptionDataConfig CreateConfiguration(DateTimeZone timeZone, IDateRule dateRule, ITimeRule timeRule)
        {
            // remove forbidden characters
            var ticker = $"{dateRule.Name}_{timeRule.Name}";

            foreach (var c in SecurityIdentifier.InvalidSymbolCharacters)
            {
                ticker = ticker.Replace(c.ToString(), "_");
            }

            var symbol = Symbol.Create(ticker, SecurityType.Base, QuantConnect.Market.USA);
            var config = new SubscriptionDataConfig(typeof(Tick),
                                                    symbol: symbol,
                                                    resolution: Resolution.Daily,
                                                    dataTimeZone: timeZone,
                                                    exchangeTimeZone: timeZone,
                                                    fillForward: false,
                                                    extendedHours: false,
                                                    isInternalFeed: true,
                                                    isCustom: false,
                                                    tickType: null,
                                                    isFilteredSubscription: false
                                                    );

            // force always open hours so we don't inadvertently mess with the scheduled firing times
            MarketHoursDatabase.FromDataFolder()
            .SetEntryAlwaysOpen(config.Market, config.Symbol.Value, config.SecurityType, config.ExchangeTimeZone);

            return(config);
        }
Ejemplo n.º 22
0
 /// <summary>
 /// Schedules the callback to run using the specified date and time rules
 /// </summary>
 /// <param name="name">The event's unique name</param>
 /// <param name="dateRule">Specifies what dates the event should run</param>
 /// <param name="timeRule">Specifies the times on those dates the event should run</param>
 /// <param name="callback">The callback to be invoked</param>
 public ScheduledEvent On(string name, IDateRule dateRule, ITimeRule timeRule, PyObject callback)
 {
     return(On(name, dateRule, timeRule, (n, d) => { using (Py.GIL()) callback.Invoke(); }));
 }
 /// <summary>
 /// Schedules the callback to run using the specified date and time rules
 /// </summary>
 /// <param name="name">The event's unique name</param>
 /// <param name="dateRule">Specifies what dates the event should run</param>
 /// <param name="timeRule">Specifies the times on those dates the event should run</param>
 /// <param name="callback">The callback to be invoked</param>
 public ScheduledEvent On(string name, IDateRule dateRule, ITimeRule timeRule, Action callback)
 {
     return(On(name, dateRule, timeRule, (n, d) => callback()));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ScheduledUniverseSelectionModel"/> class using the algorithm's time zone
 /// </summary>
 /// <param name="dateRule">Date rule defines what days the universe selection function will be invoked</param>
 /// <param name="timeRule">Time rule defines what times on each day selected by date rule the universe selection function will be invoked</param>
 /// <param name="selector">Selector function accepting the date time firing time and returning the universe selected symbols</param>
 /// <param name="settings">Universe settings for subscriptions added via this universe, null will default to algorithm's universe settings</param>
 public ScheduledUniverseSelectionModel(IDateRule dateRule, ITimeRule timeRule, PyObject selector, UniverseSettings settings = null)
     : this(null, dateRule, timeRule, selector, settings)
 {
 }
Ejemplo n.º 25
0
 /// <summary>
 /// Schedules the callback to run using the specified date and time rules
 /// </summary>
 /// <param name="dateRule">Specifies what dates the event should run</param>
 /// <param name="timeRule">Specifies the times on those dates the event should run</param>
 /// <param name="callback">The callback to be invoked</param>
 public ScheduledEvent On(IDateRule dateRule, ITimeRule timeRule, Action callback)
 {
     return On(dateRule, timeRule, (name, time) => callback());
 }
Ejemplo n.º 26
0
        /// <summary>
        /// Schedules the training code to run using the specified date and time rules
        /// </summary>
        /// <param name="dateRule">Specifies what dates the event should run</param>
        /// <param name="timeRule">Specifies the times on those dates the event should run</param>
        /// <param name="trainingCode">The training code to be invoked</param>
        public ScheduledEvent Training(IDateRule dateRule, ITimeRule timeRule, Action <DateTime> trainingCode)
        {
            var name = $"{dateRule.Name}: {timeRule.Name}";

            return(On(name, dateRule, timeRule, (n, time) => trainingCode(time)));
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Schedules the training code to run using the specified date and time rules
        /// </summary>
        /// <param name="dateRule">Specifies what dates the event should run</param>
        /// <param name="timeRule">Specifies the times on those dates the event should run</param>
        /// <param name="trainingCode">The training code to be invoked</param>
        public ScheduledEvent Training(IDateRule dateRule, ITimeRule timeRule, PyObject trainingCode)
        {
            var name = $"{dateRule.Name}: {timeRule.Name}";

            return(On(name, dateRule, timeRule, (n, time) => { using (Py.GIL()) trainingCode.Invoke(); }));
        }
Ejemplo n.º 28
0
 /// <summary>
 /// Schedules the callback to run using the specified date and time rules
 /// </summary>
 /// <param name="dateRule">Specifies what dates the event should run</param>
 /// <param name="timeRule">Specifies the times on those dates the event should run</param>
 /// <param name="callback">The callback to be invoked</param>
 public ScheduledEvent On(IDateRule dateRule, ITimeRule timeRule, Action<string, DateTime> callback)
 {
     var name = dateRule.Name + ": " + timeRule.Name;
     return On(name, dateRule, timeRule, callback);
 }
 /// <summary>
 /// Schedules the callback to run using the specified date and time rules
 /// </summary>
 /// <param name="dateRule">Specifies what dates the event should run</param>
 /// <param name="timeRule">Specifies the times on those dates the event should run</param>
 /// <param name="callback">The callback to be invoked</param>
 public ScheduledEvent On(IDateRule dateRule, ITimeRule timeRule, Action callback)
 {
     return(On(dateRule, timeRule, (name, time) => callback()));
 }
        /// <summary>
        /// Schedules the callback to run using the specified date and time rules
        /// </summary>
        /// <param name="dateRule">Specifies what dates the event should run</param>
        /// <param name="timeRule">Specifies the times on those dates the event should run</param>
        /// <param name="callback">The callback to be invoked</param>
        public ScheduledEvent On(IDateRule dateRule, ITimeRule timeRule, Action <string, DateTime> callback)
        {
            var name = dateRule.Name + ": " + timeRule.Name;

            return(On(name, dateRule, timeRule, callback));
        }
Ejemplo n.º 31
0
 /// <summary>
 /// Schedules the callback to run using the specified date and time rules
 /// </summary>
 /// <param name="name">The event's unique name</param>
 /// <param name="dateRule">Specifies what dates the event should run</param>
 /// <param name="timeRule">Specifies the times on those dates the event should run</param>
 /// <param name="callback">The callback to be invoked</param>
 public ScheduledEvent On(string name, IDateRule dateRule, ITimeRule timeRule, Action callback)
 {
     return On(name, dateRule, timeRule, (n, d) => callback());
 }
Ejemplo n.º 32
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ScheduledUniverseSelectionModel"/> class using the algorithm's time zone
 /// </summary>
 /// <param name="dateRule">Date rule defines what days the universe selection function will be invoked</param>
 /// <param name="timeRule">Time rule defines what times on each day selected by date rule the universe selection function will be invoked</param>
 /// <param name="selector">Selector function accepting the date time firing time and returning the universe selected symbols</param>
 /// <param name="settings">Universe settings for subscriptions added via this universe, null will default to algorithm's universe settings</param>
 /// <param name="initializer">Security initializer for new securities created via this universe, null will default to algorithm's security initializer</param>
 public ScheduledUniverseSelectionModel(IDateRule dateRule, ITimeRule timeRule, PyObject selector, UniverseSettings settings = null, ISecurityInitializer initializer = null)
     : this(null, dateRule, timeRule, selector, settings, initializer)
 {
 }
Ejemplo n.º 33
0
 /// <summary>
 /// Schedules the callback to run using the specified date and time rules
 /// </summary>
 /// <param name="name">The event's unique name</param>
 /// <param name="dateRule">Specifies what dates the event should run</param>
 /// <param name="timeRule">Specifies the times on those dates the event should run</param>
 /// <param name="callback">The callback to be invoked</param>
 public ScheduledEvent On(string name, IDateRule dateRule, ITimeRule timeRule, Action<string, DateTime> callback)
 {
     // back the date up to ensure we get all events, the event scheduler will skip past events that whose time has passed
     var dates = dateRule.GetDates(_securities.UtcTime.Date.AddDays(-1), Time.EndOfTime);
     var eventTimes = timeRule.CreateUtcEventTimes(dates);
     var scheduledEvent = new ScheduledEvent(name, eventTimes, callback);
     Add(scheduledEvent);
     return scheduledEvent;
 }