Lean  $LEAN_TAG$
QuantConnect.Lean.Engine.RealTime.LiveTradingRealTimeHandler Class Reference

Live trading realtime event processing. More...

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

Public Member Functions

override void Setup (IAlgorithm algorithm, AlgorithmNodePacket job, IResultHandler resultHandler, IApi api, IIsolatorLimitResultProvider isolatorLimitProvider)
 Initializes the real time handler for the specified algorithm and job More...
 
override void SetTime (DateTime time)
 Set the current time. If the date changes re-start the realtime event setup routines. More...
 
override void ScanPastEvents (DateTime time)
 Scan for past events that didn't fire because there was no data at the scheduled time. More...
 
override void Exit ()
 Stop the real time thread More...
 
- Public Member Functions inherited from QuantConnect.Lean.Engine.RealTime.BacktestingRealTimeHandler
override void Add (ScheduledEvent scheduledEvent)
 Adds the specified event to the schedule More...
 
override void Remove (ScheduledEvent scheduledEvent)
 Removes the specified event from the schedule More...
 
- Public Member Functions inherited from QuantConnect.Lean.Engine.RealTime.BaseRealTimeHandler
void OnSecuritiesChanged (SecurityChanges changes)
 Event fired each time that we add/remove securities from the data feed More...
 

Protected Member Functions

override int GetTimeMonitorTimeout ()
 Get's the timeout the scheduled task time monitor should use More...
 
virtual void RefreshMarketHours (DateTime date)
 Refresh the market hours for each security in the given date More...
 
virtual void RefreshSymbolProperties ()
 Refresh the symbol properties for each security More...
 
virtual void UpdateMarketHours (Security security)
 Updates the market hours for the specified security. More...
 
virtual void UpdateSymbolProperties (Security security)
 Updates the symbol properties for the specified security. More...
 
virtual void ResetMarketHoursDatabase ()
 Resets the market hours database, forcing a reload when reused. Called in tests where multiple algorithms are run sequentially, and we need to guarantee that every test starts with the same environment. More...
 
- Protected Member Functions inherited from QuantConnect.Lean.Engine.RealTime.BaseRealTimeHandler
int GetScheduledEventUniqueId ()
 Gets a new scheduled event unique id More...
 

Properties

MarketHoursDatabase MarketHoursDatabase = MarketHoursDatabase.FromDataFolder() [get, set]
 Gets the current market hours database instance More...
 
SymbolPropertiesDatabase SymbolPropertiesDatabase = SymbolPropertiesDatabase.FromDataFolder() [get, set]
 Gets the current symbol properties database instance More...
 
virtual ITimeProvider TimeProvider = RealTimeProvider.Instance [get]
 Gets the time provider More...
 
override bool IsActive [get, protected set]
 Boolean flag indicating thread state. More...
 
- Properties inherited from QuantConnect.Lean.Engine.RealTime.BacktestingRealTimeHandler
override bool IsActive [get, protected set]
 Flag indicating the hander thread is completely finished and ready to dispose. this doesn't run as its own thread More...
 
- Properties inherited from QuantConnect.Lean.Engine.RealTime.BaseRealTimeHandler
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...
 

Additional Inherited Members

- Static Public Member Functions inherited from QuantConnect.Lean.Engine.RealTime.BacktestingRealTimeHandler
static void SortFirstElement (IList< ScheduledEvent > scheduledEvents)
 Sorts the first element of the provided list and supposes the rest of the collection is sorted. Supposes the collection has at least 1 element More...
 

Detailed Description

Live trading realtime event processing.

Definition at line 34 of file LiveTradingRealTimeHandler.cs.

Member Function Documentation

◆ Setup()

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

Initializes the real time handler for the specified algorithm and job

Reimplemented from QuantConnect.Lean.Engine.RealTime.BacktestingRealTimeHandler.

Definition at line 66 of file LiveTradingRealTimeHandler.cs.

Here is the call graph for this function:

◆ GetTimeMonitorTimeout()

override int QuantConnect.Lean.Engine.RealTime.LiveTradingRealTimeHandler.GetTimeMonitorTimeout ( )
protectedvirtual

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

Reimplemented from QuantConnect.Lean.Engine.RealTime.BaseRealTimeHandler.

Definition at line 90 of file LiveTradingRealTimeHandler.cs.

◆ RefreshMarketHours()

virtual void QuantConnect.Lean.Engine.RealTime.LiveTradingRealTimeHandler.RefreshMarketHours ( DateTime  date)
protectedvirtual

Refresh the market hours for each security in the given date

Each time this method is called, the MarketHoursDatabase is reset

Definition at line 136 of file LiveTradingRealTimeHandler.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RefreshSymbolProperties()

virtual void QuantConnect.Lean.Engine.RealTime.LiveTradingRealTimeHandler.RefreshSymbolProperties ( )
protectedvirtual

Refresh the symbol properties for each security

  • Each time this method is called, the SymbolPropertiesDatabase is reset
  • Made protected virtual for testing purposes

Definition at line 159 of file LiveTradingRealTimeHandler.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetTime()

override void QuantConnect.Lean.Engine.RealTime.LiveTradingRealTimeHandler.SetTime ( DateTime  time)
virtual

Set the current time. If the date changes re-start the realtime event setup routines.

Parameters
time

Reimplemented from QuantConnect.Lean.Engine.RealTime.BacktestingRealTimeHandler.

Definition at line 178 of file LiveTradingRealTimeHandler.cs.

◆ ScanPastEvents()

override void QuantConnect.Lean.Engine.RealTime.LiveTradingRealTimeHandler.ScanPastEvents ( DateTime  time)
virtual

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

Parameters
timeCurrent time.

Reimplemented from QuantConnect.Lean.Engine.RealTime.BacktestingRealTimeHandler.

Definition at line 197 of file LiveTradingRealTimeHandler.cs.

◆ Exit()

override void QuantConnect.Lean.Engine.RealTime.LiveTradingRealTimeHandler.Exit ( )
virtual

Stop the real time thread

Reimplemented from QuantConnect.Lean.Engine.RealTime.BaseRealTimeHandler.

Definition at line 210 of file LiveTradingRealTimeHandler.cs.

◆ UpdateMarketHours()

virtual void QuantConnect.Lean.Engine.RealTime.LiveTradingRealTimeHandler.UpdateMarketHours ( Security  security)
protectedvirtual

Updates the market hours for the specified security.

  • This is done after a MHDB refresh
  • Made protected virtual for testing purposes

Definition at line 224 of file LiveTradingRealTimeHandler.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateSymbolProperties()

virtual void QuantConnect.Lean.Engine.RealTime.LiveTradingRealTimeHandler.UpdateSymbolProperties ( Security  security)
protectedvirtual

Updates the symbol properties for the specified security.

  • This is done after a SPDB refresh
  • Made protected virtual for testing purposes

Definition at line 241 of file LiveTradingRealTimeHandler.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ResetMarketHoursDatabase()

virtual void QuantConnect.Lean.Engine.RealTime.LiveTradingRealTimeHandler.ResetMarketHoursDatabase ( )
protectedvirtual

Resets the market hours database, forcing a reload when reused. Called in tests where multiple algorithms are run sequentially, and we need to guarantee that every test starts with the same environment.

Definition at line 253 of file LiveTradingRealTimeHandler.cs.

Here is the caller graph for this function:

Property Documentation

◆ MarketHoursDatabase

MarketHoursDatabase QuantConnect.Lean.Engine.RealTime.LiveTradingRealTimeHandler.MarketHoursDatabase = MarketHoursDatabase.FromDataFolder()
getsetprotected

Gets the current market hours database instance

Definition at line 43 of file LiveTradingRealTimeHandler.cs.

◆ SymbolPropertiesDatabase

SymbolPropertiesDatabase QuantConnect.Lean.Engine.RealTime.LiveTradingRealTimeHandler.SymbolPropertiesDatabase = SymbolPropertiesDatabase.FromDataFolder()
getsetprotected

Gets the current symbol properties database instance

Definition at line 48 of file LiveTradingRealTimeHandler.cs.

◆ TimeProvider

virtual ITimeProvider QuantConnect.Lean.Engine.RealTime.LiveTradingRealTimeHandler.TimeProvider = RealTimeProvider.Instance
getprotected

Gets the time provider

This should be fixed to RealTimeHandler, but made a protected property for testing purposes

Definition at line 56 of file LiveTradingRealTimeHandler.cs.

◆ IsActive

override bool QuantConnect.Lean.Engine.RealTime.LiveTradingRealTimeHandler.IsActive
getprotected set

Boolean flag indicating thread state.

Definition at line 61 of file LiveTradingRealTimeHandler.cs.


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