FuturesOptionsMarginModel
QuantConnect.Securities.Option.FuturesOptionsMarginModel
FuturesOptionsMarginModel(
required_free_buying_power_percent: float = 0,
future_option: Option = None,
)
Bases: FutureMarginModel
Defines a margin model for future options (an option with a future as its underlying). We re-use the FutureMarginModel implementation and multiply its results by 1.5x to simulate the increased margins seen for future options.
Creates an instance of FutureOptionMarginModel
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
|
future_option
|
Option
|
Option Security containing a Future security as the underlying |
None
|
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.
enable_intraday_margins
enable_intraday_margins: bool
True will enable usage of intraday margins.
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
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parameters
|
InitialMarginParameters
|
An object containing the security and quantity of shares |
required |
Returns:
| Type | Description |
|---|---|
InitialMargin
|
The initial margin required for the option (i.e. the equity required to enter a position for this option). |
get_maintenance_margin
get_maintenance_margin(
parameters: MaintenanceMarginParameters,
) -> MaintenanceMargin
Gets the margin currently alloted 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 option. |
get_margin_requirement
get_margin_requirement(
option: Option,
underlying_requirement: float,
position_side: PositionSide = ...,
) -> int
Get's the margin requirement for a future option based on the underlying future margin requirement and the position side to trade. FOPs margin requirement is an 'S' curve based on the underlying requirement around it's current price, see https://en.wikipedia.org/wiki/Logistic_function
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
option
|
Option
|
The future option contract to trade |
required |
underlying_requirement
|
float
|
The underlying future associated margin requirement |
required |
position_side
|
PositionSide
|
The position side to trade, long by default. This is because short positions require higher margin requirements |
...
|
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_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_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_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_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. |
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. |
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_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. |