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

Defines a set up handler that initializes the algorithm instance using values retrieved from the user's brokerage account More...

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

Public Member Functions

 BrokerageSetupHandler ()
 Initializes a new BrokerageSetupHandler More...
 
IAlgorithm CreateAlgorithmInstance (AlgorithmNodePacket algorithmNodePacket, string assemblyPath)
 Create a new instance of an algorithm from a physical dll path. More...
 
IBrokerage CreateBrokerage (AlgorithmNodePacket algorithmNodePacket, IAlgorithm uninitializedAlgorithm, out IBrokerageFactory factory)
 Creates the brokerage as specified by the job packet More...
 
bool Setup (SetupHandlerParameters parameters)
 Primary entry point to setup a new algorithm More...
 
void Dispose ()
 Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. More...
 

Static Public Attributes

static string MaxAllocationLimitConfig = "max-allocation-limit"
 Max allocation limit configuration variable name More...
 

Protected Member Functions

bool LoadExistingHoldingsAndOrders (IBrokerage brokerage, IAlgorithm algorithm, SetupHandlerParameters parameters)
 Loads existing holdings and orders More...
 
void GetOpenOrders (IAlgorithm algorithm, IResultHandler resultHandler, ITransactionHandler transactionHandler, IBrokerage brokerage)
 Get the open orders from a brokerage. Adds Orders.Order and Orders.OrderTicket to the transaction handler More...
 

Properties

WorkerThread WorkerThread [get, 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...
 
- 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

Defines a set up handler that initializes the algorithm instance using values retrieved from the user's brokerage account

Definition at line 41 of file BrokerageSetupHandler.cs.

Constructor & Destructor Documentation

◆ BrokerageSetupHandler()

QuantConnect.Lean.Engine.Setup.BrokerageSetupHandler.BrokerageSetupHandler ( )

Initializes a new BrokerageSetupHandler

Definition at line 85 of file BrokerageSetupHandler.cs.

Member Function Documentation

◆ CreateAlgorithmInstance()

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

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 98 of file BrokerageSetupHandler.cs.

Here is the call graph for this function:

◆ CreateBrokerage()

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

Creates the brokerage as specified by the job packet

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 118 of file BrokerageSetupHandler.cs.

Here is the call graph for this function:

◆ Setup()

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

Primary entry point to setup a new algorithm

Parameters
parametersThe parameters object to use
Returns
True on successfully setting up the algorithm state, or false on error.

Implements QuantConnect.Lean.Engine.Setup.ISetupHandler.

Definition at line 145 of file BrokerageSetupHandler.cs.

Here is the call graph for this function:

◆ LoadExistingHoldingsAndOrders()

bool QuantConnect.Lean.Engine.Setup.BrokerageSetupHandler.LoadExistingHoldingsAndOrders ( IBrokerage  brokerage,
IAlgorithm  algorithm,
SetupHandlerParameters  parameters 
)
protected

Loads existing holdings and orders

Definition at line 388 of file BrokerageSetupHandler.cs.

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

◆ GetOpenOrders()

void QuantConnect.Lean.Engine.Setup.BrokerageSetupHandler.GetOpenOrders ( IAlgorithm  algorithm,
IResultHandler  resultHandler,
ITransactionHandler  transactionHandler,
IBrokerage  brokerage 
)
protected

Get the open orders from a brokerage. Adds Orders.Order and Orders.OrderTicket to the transaction handler

Parameters
algorithmAlgorithm instance
resultHandlerThe configured result handler
transactionHandlerThe configurated transaction handler
brokerageBrokerage output instance

Definition at line 473 of file BrokerageSetupHandler.cs.

Here is the call graph for this function:

◆ Dispose()

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

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

<filterpriority>2</filterpriority>

Definition at line 510 of file BrokerageSetupHandler.cs.

Here is the call graph for this function:

Member Data Documentation

◆ MaxAllocationLimitConfig

string QuantConnect.Lean.Engine.Setup.BrokerageSetupHandler.MaxAllocationLimitConfig = "max-allocation-limit"
static

Max allocation limit configuration variable name

Definition at line 46 of file BrokerageSetupHandler.cs.

Property Documentation

◆ WorkerThread

WorkerThread QuantConnect.Lean.Engine.Setup.BrokerageSetupHandler.WorkerThread
getset

The worker thread instance the setup handler should use

Definition at line 51 of file BrokerageSetupHandler.cs.

◆ Errors

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

Any errors from the initialization stored here:

Definition at line 56 of file BrokerageSetupHandler.cs.

◆ MaximumRuntime

TimeSpan QuantConnect.Lean.Engine.Setup.BrokerageSetupHandler.MaximumRuntime
get

Get the maximum runtime for this algorithm job.

Definition at line 61 of file BrokerageSetupHandler.cs.

◆ StartingPortfolioValue

decimal QuantConnect.Lean.Engine.Setup.BrokerageSetupHandler.StartingPortfolioValue
get

Algorithm starting capital for statistics calculations

Definition at line 66 of file BrokerageSetupHandler.cs.

◆ StartingDate

DateTime QuantConnect.Lean.Engine.Setup.BrokerageSetupHandler.StartingDate
get

Start date for analysis loops to search for data.

Definition at line 71 of file BrokerageSetupHandler.cs.

◆ MaxOrders

int QuantConnect.Lean.Engine.Setup.BrokerageSetupHandler.MaxOrders
get

Maximum number of orders for the algorithm run – applicable for backtests only.

Definition at line 76 of file BrokerageSetupHandler.cs.


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