Lean
$LEAN_TAG$
|
Option strategy buying power model More...
Public Member Functions | |
OptionStrategyPositionGroupBuyingPowerModel (OptionStrategy optionStrategy) | |
Creates a new instance for a target option strategy More... | |
override MaintenanceMargin | GetMaintenanceMargin (PositionGroupMaintenanceMarginParameters parameters) |
Gets the margin currently allocated to the specified holding More... | |
override InitialMargin | GetInitialMarginRequirement (PositionGroupInitialMarginParameters parameters) |
The margin that must be held in order to increase the position by the provided quantity More... | |
override InitialMargin | GetInitialMarginRequiredForOrder (PositionGroupInitialMarginForOrderParameters parameters) |
Gets the total margin required to execute the specified order in units of the account currency including fees More... | |
override string | ToString () |
Returns a string that represents the current object. More... | |
Public Member Functions inherited from QuantConnect.Securities.Positions.PositionGroupBuyingPowerModel | |
virtual ReservedBuyingPowerImpact | GetReservedBuyingPowerImpact (ReservedBuyingPowerImpactParameters parameters) |
Computes the impact on the portfolio's buying power from adding the position group to the portfolio. This is a 'what if' analysis to determine what the state of the portfolio would be if these changes were applied. The delta (before - after) is the margin requirement for adding the positions and if the margin used after the changes are applied is less than the total portfolio value, this indicates sufficient capital. More... | |
virtual HasSufficientBuyingPowerForOrderResult | HasSufficientBuyingPowerForOrder (HasSufficientPositionGroupBuyingPowerForOrderParameters parameters) |
Check if there is sufficient buying power for the position group to execute this order. More... | |
virtual ReservedBuyingPowerForPositionGroup | GetReservedBuyingPowerForPositionGroup (ReservedBuyingPowerForPositionGroupParameters parameters) |
Computes the amount of buying power reserved by the provided position group More... | |
virtual GetMaximumLotsResult | GetMaximumLotsForTargetBuyingPower (GetMaximumLotsForTargetBuyingPowerParameters parameters) |
Get the maximum position group order quantity to obtain a position with a given buying power percentage. Will not take into account free buying power. More... | |
virtual GetMaximumLotsResult | GetMaximumLotsForDeltaBuyingPower (GetMaximumLotsForDeltaBuyingPowerParameters parameters) |
Get the maximum market position group order quantity to obtain a delta in the buying power used by a position group. The deltas sign defines the position side to apply it to, positive long, negative short. More... | |
PositionGroupBuyingPower | GetPositionGroupBuyingPower (PositionGroupBuyingPowerParameters parameters) |
Gets the buying power available for a position group trade More... | |
virtual bool | Equals (IPositionGroupBuyingPowerModel other) |
Indicates whether the current object is equal to another object of the same type. More... | |
override bool | Equals (object obj) |
Determines whether the specified object is equal to the current object. More... | |
override int | GetHashCode () |
Serves as the default hash function. More... | |
decimal | GetPositionGroupOrderQuantity (SecurityPortfolioManager portfolio, IPositionGroup currentPositionGroup, decimal currentUsedMargin, decimal targetFinalMargin, IPositionGroup groupUnit, decimal unitMargin, out decimal finalMargin) |
Helper method 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... | |
Protected Member Functions | |
override decimal | GetContemplatedGroupsInitialMargin (SecurityPortfolioManager portfolio, PositionGroupCollection contemplatedGroups, List< IPosition > ordersPositions) |
Gets the initial margin required for the specified contemplated position group. Used by QuantConnect.Securities.Positions.PositionGroupBuyingPowerModel.GetReservedBuyingPowerImpact to get the contemplated groups margin. More... | |
Protected Member Functions inherited from QuantConnect.Securities.Positions.PositionGroupBuyingPowerModel | |
PositionGroupBuyingPowerModel (decimal requiredFreeBuyingPowerPercent=0m) | |
Initializes a new instance of the PositionGroupBuyingPowerModel class More... | |
virtual HasSufficientBuyingPowerForOrderResult | PassesPositionGroupSpecificBuyingPowerForOrderChecks (HasSufficientPositionGroupBuyingPowerForOrderParameters parameters, decimal availableBuyingPower) |
Provides a mechanism for derived types to add their own buying power for order checks without needing to recompute the available buying power. Implementations should return null if all checks pass and should return an instance of HasSufficientBuyingPowerForOrderResult with IsSufficient=false if it fails. More... | |
virtual decimal | ToAccountCurrency (SecurityPortfolioManager portfolio, CashAmount cash) |
Helper function to convert a CashAmount to the account currency More... | |
virtual decimal | GetOrderFeeInAccountCurrency (SecurityPortfolioManager portfolio, IPositionGroup positionGroup) |
Helper function to compute the order fees associated with executing market orders for the specified positionGroup More... | |
Additional Inherited Members | |
Static Protected Member Functions inherited from QuantConnect.Securities.Positions.PositionGroupBuyingPowerModel | |
static bool | UnableToConverge (decimal currentMarginDifference, decimal lastMarginDifference, IPositionGroup groupUnit, SecurityPortfolioManager portfolio, decimal positionGroupQuantity, decimal targetMargin, decimal currentMargin, decimal absUnitMargin, out ArgumentException error) |
Checks if the margin difference is not growing in final margin calculation, just making sure we don't end up in an infinite loop. This function was split out to support derived types using the same error message as well as removing the added noise of the check and message creation. More... | |
Properties inherited from QuantConnect.Securities.Positions.PositionGroupBuyingPowerModel | |
decimal | RequiredFreeBuyingPowerPercent [get] |
Gets the percentage of portfolio buying power to leave as a buffer More... | |
Option strategy buying power model
Reference used https://www.interactivebrokers.com/en/index.php?f=26660
Definition at line 32 of file OptionStrategyPositionGroupBuyingPowerModel.cs.
QuantConnect.Securities.Option.OptionStrategyPositionGroupBuyingPowerModel.OptionStrategyPositionGroupBuyingPowerModel | ( | OptionStrategy | optionStrategy | ) |
Creates a new instance for a target option strategy
optionStrategy | The option strategy to model |
Definition at line 40 of file OptionStrategyPositionGroupBuyingPowerModel.cs.
|
virtual |
Gets the margin currently allocated to the specified holding
parameters | An object containing the security |
Implements QuantConnect.Securities.Positions.PositionGroupBuyingPowerModel.
Definition at line 50 of file OptionStrategyPositionGroupBuyingPowerModel.cs.
|
virtual |
The margin that must be held in order to increase the position by the provided quantity
parameters | An object containing the security and quantity |
Implements QuantConnect.Securities.Positions.PositionGroupBuyingPowerModel.
Definition at line 288 of file OptionStrategyPositionGroupBuyingPowerModel.cs.
|
virtual |
Gets the total margin required to execute the specified order in units of the account currency including fees
parameters | An object containing the portfolio, the security and the order |
Implements QuantConnect.Securities.Positions.PositionGroupBuyingPowerModel.
Definition at line 433 of file OptionStrategyPositionGroupBuyingPowerModel.cs.
|
protectedvirtual |
Gets the initial margin required for the specified contemplated position group. Used by QuantConnect.Securities.Positions.PositionGroupBuyingPowerModel.GetReservedBuyingPowerImpact to get the contemplated groups margin.
Reimplemented from QuantConnect.Securities.Positions.PositionGroupBuyingPowerModel.
Definition at line 450 of file OptionStrategyPositionGroupBuyingPowerModel.cs.
override string QuantConnect.Securities.Option.OptionStrategyPositionGroupBuyingPowerModel.ToString | ( | ) |
Returns a string that represents the current object.
Definition at line 488 of file OptionStrategyPositionGroupBuyingPowerModel.cs.