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

Provides an implementation of IIsolatorLimitResultProvider that tracks the algorithm manager's time loops and enforces a maximum amount of time that each time loop may take to execute. The isolator uses the result provided by IsWithinLimit to determine if it should terminate the algorithm for violation of the imposed limits. More...

Inheritance diagram for QuantConnect.Lean.Engine.AlgorithmTimeLimitManager:
[legend]

Public Member Functions

 AlgorithmTimeLimitManager (ITokenBucket additionalTimeBucket, TimeSpan timeLoopMaximum)
 Initializes a new instance of AlgorithmTimeLimitManager to manage the creation of IsolatorLimitResult instances as it pertains to the algorithm manager's time loop More...
 
void StartNewTimeStep ()
 Invoked by the algorithm at the start of each time loop. This resets the current time step elapsed time. More...
 
IsolatorLimitResult IsWithinLimit ()
 Determines whether or not the algorithm time loop is considered within the limits More...
 
void RequestAdditionalTime (int minutes)
 Requests additional time to continue executing the current time step. At time of writing, this is intended to be used to provide training scheduled events additional time to allow complex training models time to execute while also preventing abuse by enforcing certain control parameters set via the job packet. More...
 
bool TryRequestAdditionalTime (int minutes)
 Attempts to requests additional time to continue executing the current time step. At time of writing, this is intended to be used to provide training scheduled events additional time to allow complex training models time to execute while also preventing abuse by enforcing certain control parameters set via the job packet. More...
 

Properties

ITokenBucket AdditionalTimeBucket [get]
 Gets the additional time bucket which is responsible for tracking additional time requested for processing via long-running scheduled events. In LEAN, we use the LeakyBucket More...
 

Detailed Description

Provides an implementation of IIsolatorLimitResultProvider that tracks the algorithm manager's time loops and enforces a maximum amount of time that each time loop may take to execute. The isolator uses the result provided by IsWithinLimit to determine if it should terminate the algorithm for violation of the imposed limits.

Definition at line 30 of file AlgorithmTimeLimitManager.cs.

Constructor & Destructor Documentation

◆ AlgorithmTimeLimitManager()

QuantConnect.Lean.Engine.AlgorithmTimeLimitManager.AlgorithmTimeLimitManager ( ITokenBucket  additionalTimeBucket,
TimeSpan  timeLoopMaximum 
)

Initializes a new instance of AlgorithmTimeLimitManager to manage the creation of IsolatorLimitResult instances as it pertains to the algorithm manager's time loop

Parameters
additionalTimeBucketProvides a bucket of additional time that can be requested to be spent to give execution time for things such as training scheduled events
timeLoopMaximumSpecifies the maximum amount of time the algorithm is permitted to spend in a single time loop. This value can be overriden if certain actions are taken by the algorithm, such as invoking the training methods.

Definition at line 55 of file AlgorithmTimeLimitManager.cs.

Member Function Documentation

◆ StartNewTimeStep()

void QuantConnect.Lean.Engine.AlgorithmTimeLimitManager.StartNewTimeStep ( )

Invoked by the algorithm at the start of each time loop. This resets the current time step elapsed time.

This class is the result of a mechanical refactor with the intention of preserving all existing behavior, including setting the

_currentTimeStepTime

to DateTime.MinValue

Definition at line 70 of file AlgorithmTimeLimitManager.cs.

Here is the caller graph for this function:

◆ IsWithinLimit()

IsolatorLimitResult QuantConnect.Lean.Engine.AlgorithmTimeLimitManager.IsWithinLimit ( )

Determines whether or not the algorithm time loop is considered within the limits

Implements QuantConnect.IIsolatorLimitResultProvider.

Definition at line 98 of file AlgorithmTimeLimitManager.cs.

◆ RequestAdditionalTime()

void QuantConnect.Lean.Engine.AlgorithmTimeLimitManager.RequestAdditionalTime ( int  minutes)

Requests additional time to continue executing the current time step. At time of writing, this is intended to be used to provide training scheduled events additional time to allow complex training models time to execute while also preventing abuse by enforcing certain control parameters set via the job packet.

Each time this method is invoked, this time limit manager will increase the allowable execution time by the specified number of whole minutes

Implements QuantConnect.IIsolatorLimitResultProvider.

Definition at line 114 of file AlgorithmTimeLimitManager.cs.

Here is the call graph for this function:

◆ TryRequestAdditionalTime()

bool QuantConnect.Lean.Engine.AlgorithmTimeLimitManager.TryRequestAdditionalTime ( int  minutes)

Attempts to requests additional time to continue executing the current time step. At time of writing, this is intended to be used to provide training scheduled events additional time to allow complex training models time to execute while also preventing abuse by enforcing certain control parameters set via the job packet.

Each time this method is invoked, this time limit manager will increase the allowable execution time by the specified number of whole minutes

Implements QuantConnect.IIsolatorLimitResultProvider.

Definition at line 132 of file AlgorithmTimeLimitManager.cs.

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

Property Documentation

◆ AdditionalTimeBucket

ITokenBucket QuantConnect.Lean.Engine.AlgorithmTimeLimitManager.AdditionalTimeBucket
get

Gets the additional time bucket which is responsible for tracking additional time requested for processing via long-running scheduled events. In LEAN, we use the LeakyBucket

Definition at line 43 of file AlgorithmTimeLimitManager.cs.


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