Lean  $LEAN_TAG$
QuantConnect.Isolator Class Reference

Isolator class - create a new instance of the algorithm and ensure it doesn't exceed memory or time execution limits. More...

Public Member Functions

 Isolator ()
 Initializes a new instance of the Isolator class More...
 
bool ExecuteWithTimeLimit (TimeSpan timeSpan, Func< IsolatorLimitResult > withinCustomLimits, Action codeBlock, long memoryCap=1024, int sleepIntervalMillis=1000, WorkerThread workerThread=null)
 Execute a code block with a maximum limit on time and memory. More...
 
bool ExecuteWithTimeLimit (TimeSpan timeSpan, Action codeBlock, long memoryCap, int sleepIntervalMillis=1000, WorkerThread workerThread=null)
 Execute a code block with a maximum limit on time and memory. More...
 

Properties

CancellationTokenSource CancellationTokenSource [get]
 Algo cancellation controls - cancel source. More...
 

Detailed Description

Isolator class - create a new instance of the algorithm and ensure it doesn't exceed memory or time execution limits.

Definition at line 28 of file Isolator.cs.

Constructor & Destructor Documentation

◆ Isolator()

QuantConnect.Isolator.Isolator ( )

Initializes a new instance of the Isolator class

Definition at line 41 of file Isolator.cs.

Member Function Documentation

◆ ExecuteWithTimeLimit() [1/2]

bool QuantConnect.Isolator.ExecuteWithTimeLimit ( TimeSpan  timeSpan,
Func< IsolatorLimitResult withinCustomLimits,
Action  codeBlock,
long  memoryCap = 1024,
int  sleepIntervalMillis = 1000,
WorkerThread  workerThread = null 
)

Execute a code block with a maximum limit on time and memory.

Parameters
timeSpanTimeout in timespan
withinCustomLimitsFunction used to determine if the codeBlock is within custom limits, such as with algorithm manager timing individual time loops, return a non-null and non-empty string with a message indicating the error/reason for stoppage
codeBlockAction codeblock to execute
memoryCapMaximum memory allocation, default 1024Mb
sleepIntervalMillisSleep interval between each check in ms
workerThreadThe worker thread instance that will execute the provided action, if null will use a Task
Returns
True if algorithm exited successfully, false if cancelled because it exceeded limits.

Definition at line 58 of file Isolator.cs.

Here is the caller graph for this function:

◆ ExecuteWithTimeLimit() [2/2]

bool QuantConnect.Isolator.ExecuteWithTimeLimit ( TimeSpan  timeSpan,
Action  codeBlock,
long  memoryCap,
int  sleepIntervalMillis = 1000,
WorkerThread  workerThread = null 
)

Execute a code block with a maximum limit on time and memory.

Parameters
timeSpanTimeout in timespan
codeBlockAction codeblock to execute
memoryCapMaximum memory allocation, default 1024Mb
sleepIntervalMillisSleep interval between each check in ms
workerThreadThe worker thread instance that will execute the provided action, if null will use a Task
Returns
True if algorithm exited successfully, false if cancelled because it exceeded limits.

Definition at line 194 of file Isolator.cs.

Here is the call graph for this function:

Property Documentation

◆ CancellationTokenSource

CancellationTokenSource QuantConnect.Isolator.CancellationTokenSource
get

Algo cancellation controls - cancel source.

Definition at line 34 of file Isolator.cs.


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