ScheduledEventFactory
QuantConnect.Lean.Engine.RealTime.ScheduledEventFactory
Bases: Object
Provides methods for creating common scheduled events
create_event_name
create_event_name(scope: str, name: str) -> str
Defines the format of event names generated by this system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scope
|
str
|
The scope of the event, example, 'Algorithm' or 'Security' |
required |
name
|
str
|
A name for this specified event in this scope, example, 'EndOfDay' |
required |
Returns:
| Type | Description |
|---|---|
str
|
A string representing a fully scoped event name. |
every_algorithm_end_of_day
every_algorithm_end_of_day(
algorithm: IAlgorithm,
result_handler: IResultHandler,
start: Union[datetime, date],
end: Union[datetime, date],
end_of_day_delta: timedelta,
current_utc_time: Optional[datetime] = None,
) -> ScheduledEvent
Creates a new ScheduledEvent that will fire before market close by the specified time
This method is deprecated. It will generate ScheduledEvents for the deprecated IAlgorithm.OnEndOfDay()
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
algorithm
|
IAlgorithm
|
The algorithm instance the event is fo |
required |
result_handler
|
IResultHandler
|
The result handler, used to communicate run time errors |
required |
start
|
Union[datetime, date]
|
The date to start the events |
required |
end
|
Union[datetime, date]
|
The date to end the events |
required |
end_of_day_delta
|
timedelta
|
The time difference between the market close and the event, positive time will fire before market close |
required |
current_utc_time
|
Optional[datetime]
|
Specfies the current time in UTC, before which, no events will be scheduled. Specify null to skip this filter. |
None
|
Returns:
| Type | Description |
|---|---|
ScheduledEvent
|
The new ScheduledEvent that will fire near market close each tradeable dat. |
every_day_at
every_day_at(
name: str,
dates: List[datetime],
time_of_day: timedelta,
callback: Callable[[str, datetime], Any],
current_utc_time: Optional[datetime] = None,
) -> ScheduledEvent
Creates a new ScheduledEvent that will fire at the specified time_of_day for every day in dates
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
An identifier for this event |
required |
dates
|
List[datetime]
|
The dates to set events for at the specified time. These act as a base time to which the time_of_day is added to, that is, the implementation does not use .Date before the addition |
required |
time_of_day
|
timedelta
|
The time each tradeable date to fire the event |
required |
callback
|
Callable[[str, datetime], Any]
|
The delegate to call when an event fires |
required |
current_utc_time
|
Optional[datetime]
|
Specfies the current time in UTC, before which, no events will be scheduled. Specify null to skip this filter. |
None
|
Returns:
| Type | Description |
|---|---|
ScheduledEvent
|
A new ScheduledEvent instance that fires events each tradeable day from the start to the finish at the specified time. |
every_security_end_of_day
every_security_end_of_day(
algorithm: IAlgorithm,
result_handler: IResultHandler,
security: Security,
start: Union[datetime, date],
end: Union[datetime, date],
end_of_day_delta: timedelta,
current_utc_time: Optional[datetime] = None,
) -> ScheduledEvent
Creates a new ScheduledEvent that will fire before market close by the specified time
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
algorithm
|
IAlgorithm
|
The algorithm instance the event is fo |
required |
result_handler
|
IResultHandler
|
The result handler, used to communicate run time errors |
required |
security
|
Security
|
The security used for defining tradeable dates |
required |
start
|
Union[datetime, date]
|
The first date for the events |
required |
end
|
Union[datetime, date]
|
The date to end the events |
required |
end_of_day_delta
|
timedelta
|
The time difference between the market close and the event, positive time will fire before market close |
required |
current_utc_time
|
Optional[datetime]
|
Specfies the current time in UTC, before which, no events will be scheduled. Specify null to skip this filter. |
None
|
Returns:
| Type | Description |
|---|---|
ScheduledEvent
|
The new ScheduledEvent that will fire near market close each tradeable dat. |