BaseRealTimeHandler
QuantConnect.Lean.Engine.RealTime.BaseRealTimeHandler
Bases: Object, IRealTimeHandler
Base class for the real time handler LiveTradingRealTimeHandler and BacktestingRealTimeHandler implementations
is_active
is_active: bool
Thread status flag.
scheduled_events
scheduled_events: ConcurrentDictionary[ScheduledEvent, int]
The scheduled events container
This codeEntityType is protected.
isolator_limit_provider
isolator_limit_provider: IIsolatorLimitResultProvider
The isolator limit result provider instance
This codeEntityType is protected.
time_monitor
time_monitor: TimeMonitor
The time monitor instance to use
This codeEntityType is protected.
add
add(scheduled_event: ScheduledEvent) -> None
Adds the specified event to the schedule
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scheduled_event
|
ScheduledEvent
|
The event to be scheduled, including the date/times the event fires and the callback |
required |
exit
exit() -> None
Stop the real time thread
get_scheduled_event_unique_id
get_scheduled_event_unique_id() -> int
Gets a new scheduled event unique id
This codeEntityType is protected.
get_time_monitor_timeout
get_time_monitor_timeout() -> int
Get's the timeout the scheduled task time monitor should use
This codeEntityType is protected.
on_securities_changed
on_securities_changed(changes: SecurityChanges) -> None
Event fired each time that we add/remove securities from the data feed
remove
remove(scheduled_event: ScheduledEvent) -> None
Removes the specified event from the schedule
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scheduled_event
|
ScheduledEvent
|
The event to be removed |
required |
scan_past_events
scan_past_events(time: Union[datetime, date]) -> None
Scan for past events that didn't fire because there was no data at the scheduled time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
Union[datetime, date]
|
Current time. |
required |
set_time
set_time(time: Union[datetime, date]) -> None
Set the current time for the event scanner (so we can use same code for backtesting and live events)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
Union[datetime, date]
|
Current real or backtest time. |
required |
setup
setup(
algorithm: IAlgorithm,
job: AlgorithmNodePacket,
result_handler: IResultHandler,
api: IApi,
isolator_limit_provider: IIsolatorLimitResultProvider,
) -> None
Initializes the real time handler for the specified algorithm and job. Adds EndOfDayEvents