Lean  $LEAN_TAG$
QuantConnect.Lean.Engine.Setup.BacktestingSetupHandler Class Reference

Backtesting setup handler processes the algorithm initialize method and sets up the internal state of the algorithm class. More...

Inheritance diagram for QuantConnect.Lean.Engine.Setup.BacktestingSetupHandler:
[legend]

Public Member Functions

 BacktestingSetupHandler ()
 Initialize the backtest setup handler. More...
 
virtual IAlgorithm CreateAlgorithmInstance (AlgorithmNodePacket algorithmNodePacket, string assemblyPath)
 Create a new instance of an algorithm from a physical dll path. More...
 
virtual IBrokerage CreateBrokerage (AlgorithmNodePacket algorithmNodePacket, IAlgorithm uninitializedAlgorithm, out IBrokerageFactory factory)
 Creates a new BacktestingBrokerage instance More...
 
bool Setup (SetupHandlerParameters parameters)
 Setup the algorithm cash, dates and data subscriptions as desired. More...
 
void Dispose ()
 Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. More...
 

Properties

WorkerThread WorkerThread [get, set]
 The worker thread instance the setup handler should use More...
 
List< Exception > Errors [get, set]
 Internal errors list from running the setup procedures. More...
 
TimeSpan MaximumRuntime [get, protected set]
 Maximum runtime of the algorithm in seconds. More...
 
decimal StartingPortfolioValue [get, protected set]
 Starting capital according to the users initialize routine. More...
 
DateTime StartingDate [get, protected set]
 Start date for analysis loops to search for data. More...
 
int MaxOrders [get, protected set]
 Maximum number of orders for this backtest. More...
 
- Properties inherited from QuantConnect.Lean.Engine.Setup.ISetupHandler
WorkerThread WorkerThread [set]
 The worker thread instance the setup handler should use More...
 
List< Exception > Errors [get, set]
 Any errors from the initialization stored here: More...
 
TimeSpan MaximumRuntime [get]
 Get the maximum runtime for this algorithm job. More...
 
decimal StartingPortfolioValue [get]
 Algorithm starting capital for statistics calculations More...
 
DateTime StartingDate [get]
 Start date for analysis loops to search for data. More...
 
int MaxOrders [get]
 Maximum number of orders for the algorithm run – applicable for backtests only. More...
 

Detailed Description

Backtesting setup handler processes the algorithm initialize method and sets up the internal state of the algorithm class.

Definition at line 34 of file BacktestingSetupHandler.cs.

Constructor & Destructor Documentation

◆ BacktestingSetupHandler()

QuantConnect.Lean.Engine.Setup.BacktestingSetupHandler.BacktestingSetupHandler ( )

Initialize the backtest setup handler.

Definition at line 74 of file BacktestingSetupHandler.cs.

Member Function Documentation

◆ CreateAlgorithmInstance()

virtual IAlgorithm QuantConnect.Lean.Engine.Setup.BacktestingSetupHandler.CreateAlgorithmInstance ( AlgorithmNodePacket  algorithmNodePacket,
string  assemblyPath 
)
virtual

Create a new instance of an algorithm from a physical dll path.

Parameters
assemblyPathThe path to the assembly's location
algorithmNodePacketDetails of the task required
Returns
A new instance of IAlgorithm, or throws an exception if there was an error

Implements QuantConnect.Lean.Engine.Setup.ISetupHandler.

Definition at line 87 of file BacktestingSetupHandler.cs.

Here is the call graph for this function:

◆ CreateBrokerage()

virtual IBrokerage QuantConnect.Lean.Engine.Setup.BacktestingSetupHandler.CreateBrokerage ( AlgorithmNodePacket  algorithmNodePacket,
IAlgorithm  uninitializedAlgorithm,
out IBrokerageFactory  factory 
)
virtual

Creates a new BacktestingBrokerage instance

Parameters
algorithmNodePacketJob packet
uninitializedAlgorithmThe algorithm instance before Initialize has been called
factoryThe brokerage factory
Returns
The brokerage instance, or throws if error creating instance

Implements QuantConnect.Lean.Engine.Setup.ISetupHandler.

Definition at line 115 of file BacktestingSetupHandler.cs.

◆ Setup()

bool QuantConnect.Lean.Engine.Setup.BacktestingSetupHandler.Setup ( SetupHandlerParameters  parameters)

Setup the algorithm cash, dates and data subscriptions as desired.

Parameters
parametersThe parameters object to use
Returns
Boolean true on successfully initializing the algorithm

Implements QuantConnect.Lean.Engine.Setup.ISetupHandler.

Definition at line 126 of file BacktestingSetupHandler.cs.

Here is the call graph for this function:

◆ Dispose()

void QuantConnect.Lean.Engine.Setup.BacktestingSetupHandler.Dispose ( )

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

<filterpriority>2</filterpriority>

Definition at line 258 of file BacktestingSetupHandler.cs.

Property Documentation

◆ WorkerThread

WorkerThread QuantConnect.Lean.Engine.Setup.BacktestingSetupHandler.WorkerThread
getset

The worker thread instance the setup handler should use

Definition at line 39 of file BacktestingSetupHandler.cs.

◆ Errors

List<Exception> QuantConnect.Lean.Engine.Setup.BacktestingSetupHandler.Errors
getset

Internal errors list from running the setup procedures.

Definition at line 44 of file BacktestingSetupHandler.cs.

◆ MaximumRuntime

TimeSpan QuantConnect.Lean.Engine.Setup.BacktestingSetupHandler.MaximumRuntime
getprotected set

Maximum runtime of the algorithm in seconds.

Maximum runtime is a formula based on the number and resolution of symbols requested, and the days backtesting

Definition at line 50 of file BacktestingSetupHandler.cs.

◆ StartingPortfolioValue

decimal QuantConnect.Lean.Engine.Setup.BacktestingSetupHandler.StartingPortfolioValue
getprotected set

Starting capital according to the users initialize routine.

Set from the user code.

See also
QCAlgorithm.SetCash(decimal)

Definition at line 57 of file BacktestingSetupHandler.cs.

◆ StartingDate

DateTime QuantConnect.Lean.Engine.Setup.BacktestingSetupHandler.StartingDate
getprotected set

Start date for analysis loops to search for data.

See also
QCAlgorithm.SetStartDate(DateTime)

Definition at line 63 of file BacktestingSetupHandler.cs.

◆ MaxOrders

int QuantConnect.Lean.Engine.Setup.BacktestingSetupHandler.MaxOrders
getprotected set

Maximum number of orders for this backtest.

To stop algorithm flooding the backtesting system with hundreds of megabytes of order data we limit it to 100 per day

Definition at line 69 of file BacktestingSetupHandler.cs.


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