Lean  $LEAN_TAG$
QuantConnect.Securities.DefaultMarginCallModel Class Reference

Represents the model responsible for picking which orders should be executed during a margin call More...

Inheritance diagram for QuantConnect.Securities.DefaultMarginCallModel:
[legend]

Public Member Functions

 DefaultMarginCallModel (SecurityPortfolioManager portfolio, IOrderProperties defaultOrderProperties, decimal marginBuffer=0.10m)
 Initializes a new instance of the DefaultMarginCallModel class More...
 
List< SubmitOrderRequestGetMarginCallOrders (out bool issueMarginCallWarning)
 Scan the portfolio and the updated data for a potential margin call situation which may get the holdings below zero! If there is a margin call, liquidate the portfolio immediately before the portfolio gets sub zero. More...
 
virtual List< OrderTicketExecuteMarginCall (IEnumerable< SubmitOrderRequest > generatedMarginCallOrders)
 Executes synchronous orders to bring the account within margin requirements. More...
 

Protected Member Functions

virtual IEnumerable< SubmitOrderRequestGenerateMarginCallOrders (MarginCallOrdersParameters parameters)
 Generates a new order for the specified security taking into account the total margin used by the account. Returns null when no margin call is to be issued. More...
 

Properties

SecurityPortfolioManager Portfolio [get]
 Gets the portfolio that margin calls will be transacted against More...
 
IOrderProperties DefaultOrderProperties [get]
 Gets the default order properties to be used in margin call orders More...
 

Detailed Description

Represents the model responsible for picking which orders should be executed during a margin call

This is a default implementation that orders the generated margin call orders by the unrealized profit (losers first) and executes each order synchronously until we're within the margin requirements

Definition at line 33 of file DefaultMarginCallModel.cs.

Constructor & Destructor Documentation

◆ DefaultMarginCallModel()

QuantConnect.Securities.DefaultMarginCallModel.DefaultMarginCallModel ( SecurityPortfolioManager  portfolio,
IOrderProperties  defaultOrderProperties,
decimal  marginBuffer = 0.10m 
)

Initializes a new instance of the DefaultMarginCallModel class

Parameters
portfolioThe portfolio object to receive margin calls
defaultOrderPropertiesThe default order properties to be used in margin call orders
marginBufferThe percent margin buffer to use when checking whether the total margin used is above the total portfolio value to generate margin call orders

Definition at line 60 of file DefaultMarginCallModel.cs.

Member Function Documentation

◆ GetMarginCallOrders()

List<SubmitOrderRequest> QuantConnect.Securities.DefaultMarginCallModel.GetMarginCallOrders ( out bool  issueMarginCallWarning)

Scan the portfolio and the updated data for a potential margin call situation which may get the holdings below zero! If there is a margin call, liquidate the portfolio immediately before the portfolio gets sub zero.

Parameters
issueMarginCallWarningSet to true if a warning should be issued to the algorithm
Returns
True for a margin call on the holdings.

Implements QuantConnect.Securities.IMarginCallModel.

Definition at line 73 of file DefaultMarginCallModel.cs.

Here is the call graph for this function:

◆ GenerateMarginCallOrders()

virtual IEnumerable<SubmitOrderRequest> QuantConnect.Securities.DefaultMarginCallModel.GenerateMarginCallOrders ( MarginCallOrdersParameters  parameters)
protectedvirtual

Generates a new order for the specified security taking into account the total margin used by the account. Returns null when no margin call is to be issued.

Parameters
parametersThe set of parameters required to generate the margin call orders
Returns
An order object representing a liquidation order to be executed to bring the account within margin requirements

Definition at line 125 of file DefaultMarginCallModel.cs.

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

◆ ExecuteMarginCall()

virtual List<OrderTicket> QuantConnect.Securities.DefaultMarginCallModel.ExecuteMarginCall ( IEnumerable< SubmitOrderRequest generatedMarginCallOrders)
virtual

Executes synchronous orders to bring the account within margin requirements.

Parameters
generatedMarginCallOrdersThese are the margin call orders that were generated by individual security margin models.
Returns
The list of orders that were actually executed

Implements QuantConnect.Securities.IMarginCallModel.

Definition at line 187 of file DefaultMarginCallModel.cs.

Here is the call graph for this function:

Property Documentation

◆ Portfolio

SecurityPortfolioManager QuantConnect.Securities.DefaultMarginCallModel.Portfolio
getprotected

Gets the portfolio that margin calls will be transacted against

Definition at line 44 of file DefaultMarginCallModel.cs.

◆ DefaultOrderProperties

IOrderProperties QuantConnect.Securities.DefaultMarginCallModel.DefaultOrderProperties
getprotected

Gets the default order properties to be used in margin call orders

Definition at line 49 of file DefaultMarginCallModel.cs.


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