FutureMarginModel
QuantConnect.Securities.Future.FutureMarginModel
FutureMarginModel(
required_free_buying_power_percent: float = 0,
security: Security = None,
)
Bases: SecurityMarginModel
Represents a simple margin model for margin futures. Margin file contains Initial and Maintenance margins
Initializes a new instance of the FutureMarginModel
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
required_free_buying_power_percent
|
float
|
The percentage used to determine the required unused buying power for the account. |
0
|
security
|
Security
|
The security that this model belongs to |
None
|
enable_intraday_margins
enable_intraday_margins: bool
True will enable usage of intraday margins.
initial_overnight_margin_requirement
initial_overnight_margin_requirement: float
Initial Overnight margin requirement for the contract effective from the date of change
maintenance_overnight_margin_requirement
maintenance_overnight_margin_requirement: float
Maintenance Overnight margin requirement for the contract effective from the date of change
initial_intraday_margin_requirement
initial_intraday_margin_requirement: float
Initial Intraday margin for the contract effective from the date of change
maintenance_intraday_margin_requirement
maintenance_intraday_margin_requirement: float
Maintenance Intraday margin requirement for the contract effective from the date of change
NULL
NULL: IBuyingPowerModel = ...
Gets an implementation of IBuyingPowerModel that does not check for sufficient buying power
required_free_buying_power_percent
required_free_buying_power_percent: float
The percentage used to determine the required unused buying power for the account.
This codeEntityType is protected.
get_initial_margin_required_for_order
get_initial_margin_required_for_order(
parameters: InitialMarginRequiredForOrderParameters,
) -> InitialMargin
Gets the total margin required to execute the specified order in units of the account currency including fees
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parameters
|
InitialMarginRequiredForOrderParameters
|
An object containing the portfolio, the security and the order |
required |
Returns:
| Type | Description |
|---|---|
InitialMargin
|
The total margin in terms of the currency quoted in the order. |
get_initial_margin_requirement
get_initial_margin_requirement(
parameters: InitialMarginParameters,
) -> InitialMargin
The margin that must be held in order to increase the position by the provided quantity
get_leverage
get_leverage(security: Security) -> float
Gets the current leverage of the security
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
security
|
Security
|
The security to get leverage for |
required |
Returns:
| Type | Description |
|---|---|
float
|
The current leverage in the security. |
get_maintenance_margin
get_maintenance_margin(
parameters: MaintenanceMarginParameters,
) -> MaintenanceMargin
Gets the margin currently allotted to the specified holding
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parameters
|
MaintenanceMarginParameters
|
An object containing the security |
required |
Returns:
| Type | Description |
|---|---|
MaintenanceMargin
|
The maintenance margin required for the. |
get_maximum_order_quantity_for_target_buying_power
get_maximum_order_quantity_for_target_buying_power(
parameters: GetMaximumOrderQuantityForTargetBuyingPowerParameters,
) -> GetMaximumOrderQuantityResult
Get the maximum market order quantity to obtain a position with a given buying power percentage. Will not take into account free buying power.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parameters
|
GetMaximumOrderQuantityForTargetBuyingPowerParameters
|
An object containing the portfolio, the security and the target signed buying power percentage |
required |
Returns:
| Type | Description |
|---|---|
GetMaximumOrderQuantityResult
|
Returns the maximum allowed market order quantity and if zero, also the reason. |
set_leverage
set_leverage(security: Security, leverage: float) -> None
Sets the leverage for the applicable securities, i.e, futures
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
security
|
Security
|
|
required |
leverage
|
float
|
The new leverage |
required |
get_buying_power
get_buying_power(
parameters: BuyingPowerParameters,
) -> BuyingPower
Gets the buying power available for a trade
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parameters
|
BuyingPowerParameters
|
A parameters object containing the algorithm's portfolio, security, and order direction |
required |
Returns:
| Type | Description |
|---|---|
BuyingPower
|
The buying power available for the trade. |
get_maximum_order_quantity_for_delta_buying_power
get_maximum_order_quantity_for_delta_buying_power(
parameters: GetMaximumOrderQuantityForDeltaBuyingPowerParameters,
) -> GetMaximumOrderQuantityResult
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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parameters
|
GetMaximumOrderQuantityForDeltaBuyingPowerParameters
|
An object containing the portfolio, the security and the delta buying power |
required |
Returns:
| Type | Description |
|---|---|
GetMaximumOrderQuantityResult
|
Returns the maximum allowed market order quantity and if zero, also the reason. |
get_reserved_buying_power_for_position
get_reserved_buying_power_for_position(
parameters: ReservedBuyingPowerForPositionParameters,
) -> ReservedBuyingPowerForPosition
Gets the amount of buying power reserved to maintain the specified position
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parameters
|
ReservedBuyingPowerForPositionParameters
|
A parameters object containing the security |
required |
Returns:
| Type | Description |
|---|---|
ReservedBuyingPowerForPosition
|
The reserved buying power in account currency. |
has_sufficient_buying_power_for_order
has_sufficient_buying_power_for_order(
parameters: HasSufficientBuyingPowerForOrderParameters,
) -> HasSufficientBuyingPowerForOrderResult
Check if there is sufficient buying power to execute this order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parameters
|
HasSufficientBuyingPowerForOrderParameters
|
An object containing the portfolio, the security and the order |
required |
Returns:
| Type | Description |
|---|---|
HasSufficientBuyingPowerForOrderResult
|
Returns buying power information for an order. |
get_amount_to_order
get_amount_to_order(
security: Security,
target_margin: float,
margin_for_one_unit: float,
final_margin: Optional[float],
) -> Tuple[float, float]
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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
security
|
Security
|
Security we are to determine order size for |
required |
target_margin
|
float
|
Target margin allocated |
required |
margin_for_one_unit
|
float
|
Margin requirement for one unit; used in our initial order guess |
required |
final_margin
|
Optional[float]
|
Output the final margin allocated to this security |
required |
Returns:
| Type | Description |
|---|---|
Tuple[float, float]
|
The size of the order to get safely to our target. |
get_margin_remaining
get_margin_remaining(
portfolio: SecurityPortfolioManager,
security: Security,
direction: OrderDirection,
) -> float
Gets the margin cash available for a trade
This codeEntityType is protected.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
portfolio
|
SecurityPortfolioManager
|
The algorithm's portfolio |
required |
security
|
Security
|
The security to be traded |
required |
direction
|
OrderDirection
|
The direction of the trade |
required |
Returns:
| Type | Description |
|---|---|
float
|
The margin available for the trade. |