Lean  $LEAN_TAG$
QuantConnect.Lean.Engine.RealTime.BaseRealTimeHandler Class Referenceabstract

Base class for the real time handler LiveTradingRealTimeHandler and BacktestingRealTimeHandler implementations More...

Inheritance diagram for QuantConnect.Lean.Engine.RealTime.BaseRealTimeHandler:
[legend]

Public Member Functions

abstract void Add (ScheduledEvent scheduledEvent)
 Adds the specified event to the schedule More...
 
abstract void Remove (ScheduledEvent scheduledEvent)
 Removes the specified event from the schedule More...
 
abstract void SetTime (DateTime time)
 Set the current time for the event scanner (so we can use same code for backtesting and live events) More...
 
abstract void ScanPastEvents (DateTime time)
 Scan for past events that didn't fire because there was no data at the scheduled time. More...
 
virtual void Setup (IAlgorithm algorithm, AlgorithmNodePacket job, IResultHandler resultHandler, IApi api, IIsolatorLimitResultProvider isolatorLimitProvider)
 Initializes the real time handler for the specified algorithm and job. Adds EndOfDayEvents More...
 
void OnSecuritiesChanged (SecurityChanges changes)
 Event fired each time that we add/remove securities from the data feed More...
 
virtual void Exit ()
 Stop the real time thread More...
 

Protected Member Functions

int GetScheduledEventUniqueId ()
 Gets a new scheduled event unique id More...
 
virtual int GetTimeMonitorTimeout ()
 Get's the timeout the scheduled task time monitor should use More...
 

Properties

abstract bool IsActive [get, protected set]
 Thread status flag. More...
 
ConcurrentDictionary< ScheduledEvent, int > ScheduledEvents = new() [get]
 The scheduled events container More...
 
IIsolatorLimitResultProvider IsolatorLimitProvider [get]
 The isolator limit result provider instance More...
 
IAlgorithm Algorithm [get]
 The algorithm instance More...
 
TimeMonitor TimeMonitor [get]
 The time monitor instance to use More...
 
- Properties inherited from QuantConnect.Lean.Engine.RealTime.IRealTimeHandler
bool IsActive [get]
 Thread status flag. More...
 

Detailed Description

Base class for the real time handler LiveTradingRealTimeHandler and BacktestingRealTimeHandler implementations

Definition at line 37 of file BaseRealTimeHandler.cs.

Member Function Documentation

◆ Add()

abstract void QuantConnect.Lean.Engine.RealTime.BaseRealTimeHandler.Add ( ScheduledEvent  scheduledEvent)
pure virtual

Adds the specified event to the schedule

Parameters
scheduledEventThe event to be scheduled, including the date/times the event fires and the callback

Implements QuantConnect.Scheduling.IEventSchedule.

Implemented in QuantConnect.Lean.Engine.RealTime.BacktestingRealTimeHandler.

◆ Remove()

abstract void QuantConnect.Lean.Engine.RealTime.BaseRealTimeHandler.Remove ( ScheduledEvent  scheduledEvent)
pure virtual

Removes the specified event from the schedule

Parameters
scheduledEventThe event to be removed

Implements QuantConnect.Scheduling.IEventSchedule.

Implemented in QuantConnect.Lean.Engine.RealTime.BacktestingRealTimeHandler.

Here is the caller graph for this function:

◆ SetTime()

abstract void QuantConnect.Lean.Engine.RealTime.BaseRealTimeHandler.SetTime ( DateTime  time)
pure virtual

Set the current time for the event scanner (so we can use same code for backtesting and live events)

Parameters
timeCurrent real or backtest time.

Implements QuantConnect.Lean.Engine.RealTime.IRealTimeHandler.

Implemented in QuantConnect.Lean.Engine.RealTime.LiveTradingRealTimeHandler, and QuantConnect.Lean.Engine.RealTime.BacktestingRealTimeHandler.

◆ ScanPastEvents()

abstract void QuantConnect.Lean.Engine.RealTime.BaseRealTimeHandler.ScanPastEvents ( DateTime  time)
pure virtual

Scan for past events that didn't fire because there was no data at the scheduled time.

Parameters
timeCurrent time.

Implements QuantConnect.Lean.Engine.RealTime.IRealTimeHandler.

Implemented in QuantConnect.Lean.Engine.RealTime.LiveTradingRealTimeHandler, and QuantConnect.Lean.Engine.RealTime.BacktestingRealTimeHandler.

◆ Setup()

virtual void QuantConnect.Lean.Engine.RealTime.BaseRealTimeHandler.Setup ( IAlgorithm  algorithm,
AlgorithmNodePacket  job,
IResultHandler  resultHandler,
IApi  api,
IIsolatorLimitResultProvider  isolatorLimitProvider 
)
virtual

Initializes the real time handler for the specified algorithm and job. Adds EndOfDayEvents

Implements QuantConnect.Lean.Engine.RealTime.IRealTimeHandler.

Reimplemented in QuantConnect.Lean.Engine.RealTime.LiveTradingRealTimeHandler, and QuantConnect.Lean.Engine.RealTime.BacktestingRealTimeHandler.

Definition at line 118 of file BaseRealTimeHandler.cs.

Here is the call graph for this function:

◆ GetScheduledEventUniqueId()

int QuantConnect.Lean.Engine.RealTime.BaseRealTimeHandler.GetScheduledEventUniqueId ( )
protected

Gets a new scheduled event unique id

This value is used to order scheduled events in a deterministic way

Definition at line 165 of file BaseRealTimeHandler.cs.

Here is the caller graph for this function:

◆ GetTimeMonitorTimeout()

virtual int QuantConnect.Lean.Engine.RealTime.BaseRealTimeHandler.GetTimeMonitorTimeout ( )
protectedvirtual

Get's the timeout the scheduled task time monitor should use

Reimplemented in QuantConnect.Lean.Engine.RealTime.LiveTradingRealTimeHandler.

Definition at line 173 of file BaseRealTimeHandler.cs.

Here is the caller graph for this function:

◆ OnSecuritiesChanged()

void QuantConnect.Lean.Engine.RealTime.BaseRealTimeHandler.OnSecuritiesChanged ( SecurityChanges  changes)

Event fired each time that we add/remove securities from the data feed

Implements QuantConnect.Lean.Engine.RealTime.IRealTimeHandler.

Definition at line 248 of file BaseRealTimeHandler.cs.

Here is the call graph for this function:

◆ Exit()

virtual void QuantConnect.Lean.Engine.RealTime.BaseRealTimeHandler.Exit ( )
virtual

Property Documentation

◆ IsActive

abstract bool QuantConnect.Lean.Engine.RealTime.BaseRealTimeHandler.IsActive
getprotected set

Thread status flag.

Definition at line 64 of file BaseRealTimeHandler.cs.

◆ ScheduledEvents

ConcurrentDictionary<ScheduledEvent, int> QuantConnect.Lean.Engine.RealTime.BaseRealTimeHandler.ScheduledEvents = new()
getprotected

The scheduled events container

Initialize this immediately since the Initialize method gets called after IAlgorithm.Initialize, so we want to be ready to accept events as soon as possible

Definition at line 72 of file BaseRealTimeHandler.cs.

◆ IsolatorLimitProvider

IIsolatorLimitResultProvider QuantConnect.Lean.Engine.RealTime.BaseRealTimeHandler.IsolatorLimitProvider
getprotected

The isolator limit result provider instance

Definition at line 77 of file BaseRealTimeHandler.cs.

◆ Algorithm

IAlgorithm QuantConnect.Lean.Engine.RealTime.BaseRealTimeHandler.Algorithm
getprotected

The algorithm instance

Definition at line 82 of file BaseRealTimeHandler.cs.

◆ TimeMonitor

TimeMonitor QuantConnect.Lean.Engine.RealTime.BaseRealTimeHandler.TimeMonitor
getprotected

The time monitor instance to use

Definition at line 87 of file BaseRealTimeHandler.cs.


The documentation for this class was generated from the following file: