Lean  $LEAN_TAG$
QuantConnect.Securities.CryptoFuture.CryptoFutureMarginModel Class Reference

The crypto future margin model which supports both Coin and USDT futures More...

Inheritance diagram for QuantConnect.Securities.CryptoFuture.CryptoFutureMarginModel:
[legend]

Public Member Functions

 CryptoFutureMarginModel (decimal leverage=25, decimal maintenanceMarginRate=0.05m, decimal maintenanceAmount=0)
 Creates a new instance More...
 
override MaintenanceMargin GetMaintenanceMargin (MaintenanceMarginParameters parameters)
 Gets the margin currently alloted to the specified holding. More...
 
override InitialMargin GetInitialMarginRequirement (InitialMarginParameters parameters)
 The margin that must be held in order to increase the position by the provided quantity More...
 
- Public Member Functions inherited from QuantConnect.Securities.SecurityMarginModel
 SecurityMarginModel ()
 Initializes a new instance of the SecurityMarginModel with no leverage (1x) More...
 
 SecurityMarginModel (decimal initialMarginRequirement, decimal maintenanceMarginRequirement, decimal requiredFreeBuyingPowerPercent)
 Initializes a new instance of the SecurityMarginModel More...
 
 SecurityMarginModel (decimal leverage, decimal requiredFreeBuyingPowerPercent=0)
 Initializes a new instance of the SecurityMarginModel More...
 
- Public Member Functions inherited from QuantConnect.Securities.BuyingPowerModel
 BuyingPowerModel ()
 Initializes a new instance of the BuyingPowerModel with no leverage (1x) More...
 
 BuyingPowerModel (decimal initialMarginRequirement, decimal maintenanceMarginRequirement, decimal requiredFreeBuyingPowerPercent)
 Initializes a new instance of the BuyingPowerModel More...
 
 BuyingPowerModel (decimal leverage, decimal requiredFreeBuyingPowerPercent=0)
 Initializes a new instance of the BuyingPowerModel More...
 
virtual decimal GetLeverage (Security security)
 Gets the current leverage of the security More...
 
virtual void SetLeverage (Security security, decimal leverage)
 Sets the leverage for the applicable securities, i.e, equities More...
 
virtual InitialMargin GetInitialMarginRequiredForOrder (InitialMarginRequiredForOrderParameters parameters)
 Gets the total margin required to execute the specified order in units of the account currency including fees More...
 
virtual HasSufficientBuyingPowerForOrderResult HasSufficientBuyingPowerForOrder (HasSufficientBuyingPowerForOrderParameters parameters)
 Check if there is sufficient buying power to execute this order. More...
 
virtual GetMaximumOrderQuantityResult GetMaximumOrderQuantityForDeltaBuyingPower (GetMaximumOrderQuantityForDeltaBuyingPowerParameters parameters)
 Get the maximum market order quantity to obtain a delta in the buying power used by a security. The deltas sign defines the position side to apply it to, positive long, negative short. More...
 
virtual GetMaximumOrderQuantityResult GetMaximumOrderQuantityForTargetBuyingPower (GetMaximumOrderQuantityForTargetBuyingPowerParameters parameters)
 Get the maximum market order quantity to obtain a position with a given buying power percentage. Will not take into account free buying power. More...
 
decimal GetAmountToOrder ([NotNull]Security security, decimal targetMargin, decimal marginForOneUnit, out decimal finalMargin)
 Helper function that determines the amount to order to get to a given target safely. Meaning it will either be at or just below target always. More...
 
virtual ReservedBuyingPowerForPosition GetReservedBuyingPowerForPosition (ReservedBuyingPowerForPositionParameters parameters)
 Gets the amount of buying power reserved to maintain the specified position More...
 
virtual BuyingPower GetBuyingPower (BuyingPowerParameters parameters)
 Gets the buying power available for a trade More...
 

Protected Member Functions

override decimal GetMarginRemaining (SecurityPortfolioManager portfolio, Security security, OrderDirection direction)
 Gets the margin cash available for a trade More...
 

Additional Inherited Members

- Static Public Attributes inherited from QuantConnect.Securities.BuyingPowerModel
static readonly IBuyingPowerModel Null = new NullBuyingPowerModel()
 Gets an implementation of IBuyingPowerModel that does not check for sufficient buying power More...
 
- Protected Attributes inherited from QuantConnect.Securities.BuyingPowerModel
decimal RequiredFreeBuyingPowerPercent
 The percentage used to determine the required unused buying power for the account. More...
 

Detailed Description

The crypto future margin model which supports both Coin and USDT futures

Definition at line 25 of file CryptoFutureMarginModel.cs.

Constructor & Destructor Documentation

◆ CryptoFutureMarginModel()

QuantConnect.Securities.CryptoFuture.CryptoFutureMarginModel.CryptoFutureMarginModel ( decimal  leverage = 25,
decimal  maintenanceMarginRate = 0.05m,
decimal  maintenanceAmount = 0 
)

Creates a new instance

Parameters
leverageThe leverage to use, used on initial margin requirements, default 25x
maintenanceMarginRateThe maintenance margin rate, default 5%
maintenanceAmountThe maintenance amount which will reduce maintenance margin requirements, default 0

Definition at line 36 of file CryptoFutureMarginModel.cs.

Member Function Documentation

◆ GetMaintenanceMargin()

override MaintenanceMargin QuantConnect.Securities.CryptoFuture.CryptoFutureMarginModel.GetMaintenanceMargin ( MaintenanceMarginParameters  parameters)
virtual

Gets the margin currently alloted to the specified holding.

Parameters
parametersAn object containing the security
Returns
The maintenance margin required for the option

Reimplemented from QuantConnect.Securities.BuyingPowerModel.

Definition at line 48 of file CryptoFutureMarginModel.cs.

Here is the caller graph for this function:

◆ GetInitialMarginRequirement()

override InitialMargin QuantConnect.Securities.CryptoFuture.CryptoFutureMarginModel.GetInitialMarginRequirement ( InitialMarginParameters  parameters)
virtual

The margin that must be held in order to increase the position by the provided quantity

Parameters
parametersAn object containing the security and quantity of shares
Returns
The initial margin required for the option (i.e. the equity required to enter a position for this option)

Reimplemented from QuantConnect.Securities.BuyingPowerModel.

Definition at line 68 of file CryptoFutureMarginModel.cs.

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

◆ GetMarginRemaining()

override decimal QuantConnect.Securities.CryptoFuture.CryptoFutureMarginModel.GetMarginRemaining ( SecurityPortfolioManager  portfolio,
Security  security,
OrderDirection  direction 
)
protectedvirtual

Gets the margin cash available for a trade

Parameters
portfolioThe algorithm's portfolio
securityThe security to be traded
directionThe direction of the trade
Returns
The margin available for the trade

What we do specially here is that instead of using the total portfolio value as potential margin remaining we only consider the collateral currency

Reimplemented from QuantConnect.Securities.BuyingPowerModel.

Definition at line 91 of file CryptoFutureMarginModel.cs.

Here is the call graph for this function:

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