Lean  $LEAN_TAG$
QuantConnect.Lean.Engine.AlgorithmManager Class Reference

Algorithm manager class executes the algorithm and generates and passes through the algorithm events. More...

Public Member Functions

 AlgorithmManager (bool liveMode, AlgorithmNodePacket job=null)
 Initializes a new instance of the AlgorithmManager class More...
 
void Run (AlgorithmNodePacket job, IAlgorithm algorithm, ISynchronizer synchronizer, ITransactionHandler transactions, IResultHandler results, IRealTimeHandler realtime, ILeanManager leanManager, CancellationTokenSource cancellationTokenSource)
 Launch the algorithm manager to run this strategy More...
 
void SetStatus (AlgorithmStatus state)
 Set the quit state. More...
 

Static Public Member Functions

static void ProcessVolatilityHistoryRequirements (IAlgorithm algorithm, bool liveMode)
 Helper method used to process securities volatility history requirements More...
 
static void HandleSplits (TimeSlice timeSlice, IAlgorithm algorithm, bool liveMode)
 Helper method to apply a split to an algorithm instance More...
 
static void HandleDividends (TimeSlice timeSlice, IAlgorithm algorithm, bool liveMode)
 Helper method to apply a dividend to an algorithm instance More...
 

Public Attributes

AlgorithmStatus State => _algorithm?.Status ?? AlgorithmStatus.Running
 Publicly accessible algorithm status More...
 
bool QuitState => State == AlgorithmStatus.Deleted
 Quit state flag for the running algorithm. When true the user has requested the backtest stops through a Quit() method. More...
 
int AlgorithmHistoryDataPoints => _algorithm?.HistoryProvider?.DataPointCount ?? 0
 Gets the number of data points of algorithm history provider More...
 

Properties

string AlgorithmId [get]
 Public access to the currently running algorithm id. More...
 
AlgorithmTimeLimitManager TimeLimit [get]
 Provides the isolator with a function for verifying that we're not spending too much time in each algorithm manager time loop More...
 
long DataPoints [get]
 Gets the number of data points processed per second More...
 

Detailed Description

Algorithm manager class executes the algorithm and generates and passes through the algorithm events.

Definition at line 46 of file AlgorithmManager.cs.

Constructor & Destructor Documentation

◆ AlgorithmManager()

QuantConnect.Lean.Engine.AlgorithmManager.AlgorithmManager ( bool  liveMode,
AlgorithmNodePacket  job = null 
)

Initializes a new instance of the AlgorithmManager class

Parameters
liveModeTrue if we're running in live mode, false for backtest mode
jobProvided by LEAN when creating a new algo manager. This is the job that the algo manager is about to execute. Research and other consumers can provide the default value of null

Definition at line 93 of file AlgorithmManager.cs.

Here is the call graph for this function:

Member Function Documentation

◆ Run()

void QuantConnect.Lean.Engine.AlgorithmManager.Run ( AlgorithmNodePacket  job,
IAlgorithm  algorithm,
ISynchronizer  synchronizer,
ITransactionHandler  transactions,
IResultHandler  results,
IRealTimeHandler  realtime,
ILeanManager  leanManager,
CancellationTokenSource  cancellationTokenSource 
)

Launch the algorithm manager to run this strategy

Parameters
jobAlgorithm job
algorithmAlgorithm instance
synchronizerInstance which implements ISynchronizer. Used to stream the data
transactionsTransaction manager object
resultsResult handler object
realtimeRealtime processing object
leanManagerILeanManager implementation that is updated periodically with the IAlgorithm instance
cancellationTokenSourceCancellation token source to monitor

Modify with caution

Definition at line 118 of file AlgorithmManager.cs.

Here is the call graph for this function:

◆ SetStatus()

void QuantConnect.Lean.Engine.AlgorithmManager.SetStatus ( AlgorithmStatus  state)

Set the quit state.

Definition at line 610 of file AlgorithmManager.cs.

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

◆ ProcessVolatilityHistoryRequirements()

static void QuantConnect.Lean.Engine.AlgorithmManager.ProcessVolatilityHistoryRequirements ( IAlgorithm  algorithm,
bool  liveMode 
)
static

Helper method used to process securities volatility history requirements

Implemented as static to facilitate testing

Parameters
algorithmThe algorithm instance
liveModeWhether the algorithm is in live mode

Definition at line 709 of file AlgorithmManager.cs.

Here is the call graph for this function:

◆ HandleSplits()

static void QuantConnect.Lean.Engine.AlgorithmManager.HandleSplits ( TimeSlice  timeSlice,
IAlgorithm  algorithm,
bool  liveMode 
)
static

Helper method to apply a split to an algorithm instance

Definition at line 725 of file AlgorithmManager.cs.

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

◆ HandleDividends()

static void QuantConnect.Lean.Engine.AlgorithmManager.HandleDividends ( TimeSlice  timeSlice,
IAlgorithm  algorithm,
bool  liveMode 
)
static

Helper method to apply a dividend to an algorithm instance

Definition at line 792 of file AlgorithmManager.cs.

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

Member Data Documentation

◆ State

AlgorithmStatus QuantConnect.Lean.Engine.AlgorithmManager.State => _algorithm?.Status ?? AlgorithmStatus.Running

Publicly accessible algorithm status

Definition at line 57 of file AlgorithmManager.cs.

◆ QuitState

bool QuantConnect.Lean.Engine.AlgorithmManager.QuitState => State == AlgorithmStatus.Deleted

Quit state flag for the running algorithm. When true the user has requested the backtest stops through a Quit() method.

See also
QCAlgorithm.Quit(String)

Definition at line 74 of file AlgorithmManager.cs.

◆ AlgorithmHistoryDataPoints

int QuantConnect.Lean.Engine.AlgorithmManager.AlgorithmHistoryDataPoints => _algorithm?.HistoryProvider?.DataPointCount ?? 0

Gets the number of data points of algorithm history provider

Definition at line 84 of file AlgorithmManager.cs.

Property Documentation

◆ AlgorithmId

string QuantConnect.Lean.Engine.AlgorithmManager.AlgorithmId
get

Public access to the currently running algorithm id.

Definition at line 62 of file AlgorithmManager.cs.

◆ TimeLimit

AlgorithmTimeLimitManager QuantConnect.Lean.Engine.AlgorithmManager.TimeLimit
get

Provides the isolator with a function for verifying that we're not spending too much time in each algorithm manager time loop

Definition at line 68 of file AlgorithmManager.cs.

◆ DataPoints

long QuantConnect.Lean.Engine.AlgorithmManager.DataPoints
get

Gets the number of data points processed per second

Definition at line 79 of file AlgorithmManager.cs.


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