Lean  $LEAN_TAG$
QuantConnect.Optimizer.LeanOptimizer Class Referenceabstract

Base Lean optimizer class in charge of handling an optimization job packet More...

Inheritance diagram for QuantConnect.Optimizer.LeanOptimizer:
[legend]

Public Member Functions

virtual void Start ()
 Starts the optimization More...
 
virtual void Dispose ()
 Disposes of any resources More...
 
int GetCurrentEstimate ()
 Returns the current optimization status and strategy estimates More...
 
Dictionary< string, string > GetRuntimeStatistics ()
 Get the current runtime statistics More...
 

Protected Member Functions

 LeanOptimizer (OptimizationNodePacket nodePacket)
 Creates a new instance More...
 
virtual void TriggerOnEndEvent ()
 Triggers the optimization job end event More...
 
abstract string RunLean (ParameterSet parameterSet, string backtestName)
 Handles starting Lean for a given parameter set More...
 
virtual string GetBacktestName (ParameterSet parameterSet)
 Get's a new backtest name More...
 
virtual void NewResult (string jsonBacktestResult, string backtestId)
 Handles a new backtest json result matching a requested backtest id More...
 
string GetLogDetails ()
 Helper method to have pretty more informative logs More...
 
abstract void AbortLean (string backtestId)
 Handles stopping Lean process More...
 
abstract void SendUpdate ()
 Sends an update of the current optimization status to the user More...
 
virtual void SetOptimizationStatus (OptimizationStatus optimizationStatus)
 Sets the current optimization status More...
 

Protected Attributes

int CompletedBacktests => _failedBacktest + _completedBacktest
 The total completed backtests count More...
 
bool Disposed => _disposed
 Indicates whether optimizer was disposed More...
 

Properties

OptimizationStatus Status = OptimizationStatus.New [get]
 The current optimization status More...
 
Target OptimizationTarget [get]
 The optimization target More...
 
ConcurrentDictionary< string, ParameterSetRunningParameterSetForBacktest [get]
 Collection holding ParameterSet for each backtest id we are waiting to finish More...
 
ConcurrentQueue< ParameterSetPendingParameterSet [get]
 Collection holding ParameterSet for each backtest id we are waiting to launch More...
 
IOptimizationStrategy Strategy [get]
 The optimization strategy being used More...
 
OptimizationNodePacket NodePacket [get]
 The optimization packet More...
 

Events

EventHandler< OptimizationResultEnded
 Event triggered when the optimization work ended More...
 

Detailed Description

Base Lean optimizer class in charge of handling an optimization job packet

Definition at line 33 of file LeanOptimizer.cs.

Constructor & Destructor Documentation

◆ LeanOptimizer()

QuantConnect.Optimizer.LeanOptimizer.LeanOptimizer ( OptimizationNodePacket  nodePacket)
protected

Creates a new instance

Parameters
nodePacketThe optimization node packet to handle

Definition at line 99 of file LeanOptimizer.cs.

Here is the call graph for this function:

Member Function Documentation

◆ Start()

virtual void QuantConnect.Optimizer.LeanOptimizer.Start ( )
virtual

Starts the optimization

Definition at line 141 of file LeanOptimizer.cs.

Here is the call graph for this function:

◆ TriggerOnEndEvent()

virtual void QuantConnect.Optimizer.LeanOptimizer.TriggerOnEndEvent ( )
protectedvirtual

Triggers the optimization job end event

Definition at line 163 of file LeanOptimizer.cs.

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

◆ RunLean()

abstract string QuantConnect.Optimizer.LeanOptimizer.RunLean ( ParameterSet  parameterSet,
string  backtestName 
)
protectedpure virtual

Handles starting Lean for a given parameter set

Parameters
parameterSetThe parameter set for the backtest to run
backtestNameThe backtest name to use
Returns
The new unique backtest id

Implemented in QuantConnect.Optimizer.Launcher.ConsoleLeanOptimizer.

◆ GetBacktestName()

virtual string QuantConnect.Optimizer.LeanOptimizer.GetBacktestName ( ParameterSet  parameterSet)
protectedvirtual

Get's a new backtest name

Definition at line 202 of file LeanOptimizer.cs.

◆ NewResult()

virtual void QuantConnect.Optimizer.LeanOptimizer.NewResult ( string  jsonBacktestResult,
string  backtestId 
)
protectedvirtual

Handles a new backtest json result matching a requested backtest id

Parameters
jsonBacktestResultThe backtest json result
backtestIdThe associated backtest id

Definition at line 212 of file LeanOptimizer.cs.

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

◆ Dispose()

virtual void QuantConnect.Optimizer.LeanOptimizer.Dispose ( )
virtual

Disposes of any resources

Definition at line 267 of file LeanOptimizer.cs.

◆ GetCurrentEstimate()

int QuantConnect.Optimizer.LeanOptimizer.GetCurrentEstimate ( )

Returns the current optimization status and strategy estimates

Definition at line 280 of file LeanOptimizer.cs.

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

◆ GetRuntimeStatistics()

Dictionary<string, string> QuantConnect.Optimizer.LeanOptimizer.GetRuntimeStatistics ( )

Get the current runtime statistics

Definition at line 288 of file LeanOptimizer.cs.

Here is the caller graph for this function:

◆ GetLogDetails()

string QuantConnect.Optimizer.LeanOptimizer.GetLogDetails ( )
protected

Helper method to have pretty more informative logs

Definition at line 309 of file LeanOptimizer.cs.

◆ AbortLean()

abstract void QuantConnect.Optimizer.LeanOptimizer.AbortLean ( string  backtestId)
protectedpure virtual

Handles stopping Lean process

Parameters
backtestIdSpecified backtest id

Implemented in QuantConnect.Optimizer.Launcher.ConsoleLeanOptimizer.

◆ SendUpdate()

abstract void QuantConnect.Optimizer.LeanOptimizer.SendUpdate ( )
protectedpure virtual

Sends an update of the current optimization status to the user

Implemented in QuantConnect.Optimizer.Launcher.ConsoleLeanOptimizer.

◆ SetOptimizationStatus()

virtual void QuantConnect.Optimizer.LeanOptimizer.SetOptimizationStatus ( OptimizationStatus  optimizationStatus)
protectedvirtual

Sets the current optimization status

Parameters
optimizationStatusThe new optimization status

Definition at line 333 of file LeanOptimizer.cs.

Here is the caller graph for this function:

Member Data Documentation

◆ CompletedBacktests

int QuantConnect.Optimizer.LeanOptimizer.CompletedBacktests => _failedBacktest + _completedBacktest
protected

The total completed backtests count

Definition at line 47 of file LeanOptimizer.cs.

◆ Disposed

bool QuantConnect.Optimizer.LeanOptimizer.Disposed => _disposed
protected

Indicates whether optimizer was disposed

Definition at line 88 of file LeanOptimizer.cs.

Property Documentation

◆ Status

OptimizationStatus QuantConnect.Optimizer.LeanOptimizer.Status = OptimizationStatus.New
getprotected

The current optimization status

Definition at line 57 of file LeanOptimizer.cs.

◆ OptimizationTarget

Target QuantConnect.Optimizer.LeanOptimizer.OptimizationTarget
getprotected

The optimization target

Definition at line 62 of file LeanOptimizer.cs.

◆ RunningParameterSetForBacktest

ConcurrentDictionary<string, ParameterSet> QuantConnect.Optimizer.LeanOptimizer.RunningParameterSetForBacktest
getprotected

Collection holding ParameterSet for each backtest id we are waiting to finish

Definition at line 67 of file LeanOptimizer.cs.

◆ PendingParameterSet

ConcurrentQueue<ParameterSet> QuantConnect.Optimizer.LeanOptimizer.PendingParameterSet
getprotected

Collection holding ParameterSet for each backtest id we are waiting to launch

We can't launch 1 million backtests at the same time

Definition at line 73 of file LeanOptimizer.cs.

◆ Strategy

IOptimizationStrategy QuantConnect.Optimizer.LeanOptimizer.Strategy
getprotected

The optimization strategy being used

Definition at line 78 of file LeanOptimizer.cs.

◆ NodePacket

OptimizationNodePacket QuantConnect.Optimizer.LeanOptimizer.NodePacket
getprotected

The optimization packet

Definition at line 83 of file LeanOptimizer.cs.

Event Documentation

◆ Ended

EventHandler<OptimizationResult> QuantConnect.Optimizer.LeanOptimizer.Ended

Event triggered when the optimization work ended

Definition at line 93 of file LeanOptimizer.cs.


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