Lean
$LEAN_TAG$
|
Provides an implementation of IPositionGroupBuyingPowerModel for groups containing exactly one security More...
Public Member Functions | |
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 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... | |
override 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... | |
override HasSufficientBuyingPowerForOrderResult | HasSufficientBuyingPowerForOrder (HasSufficientPositionGroupBuyingPowerForOrderParameters parameters) |
Check if there is sufficient buying power for the position group to execute this order. 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 ReservedBuyingPowerForPositionGroup | GetReservedBuyingPowerForPositionGroup (ReservedBuyingPowerForPositionGroupParameters parameters) |
Computes the amount of buying power reserved by the provided position group 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 HasSufficientBuyingPowerForOrderResult | PassesPositionGroupSpecificBuyingPowerForOrderChecks (HasSufficientPositionGroupBuyingPowerForOrderParameters parameters, decimal availableBuyingPower) |
Additionally check initial margin requirements if the algorithm only has default position groups More... | |
Protected Member Functions inherited from QuantConnect.Securities.Positions.PositionGroupBuyingPowerModel | |
PositionGroupBuyingPowerModel (decimal requiredFreeBuyingPowerPercent=0m) | |
Initializes a new instance of the PositionGroupBuyingPowerModel class More... | |
virtual decimal | GetContemplatedGroupsInitialMargin (SecurityPortfolioManager portfolio, PositionGroupCollection contemplatedGroups, List< IPosition > ordersPositions) |
Gets the initial margin required for the specified contemplated position group. Used by GetReservedBuyingPowerImpact to get the contemplated groups margin. 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... | |
Provides an implementation of IPositionGroupBuyingPowerModel for groups containing exactly one security
Definition at line 23 of file SecurityPositionGroupBuyingPowerModel.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 30 of file SecurityPositionGroupBuyingPowerModel.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 53 of file SecurityPositionGroupBuyingPowerModel.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 72 of file SecurityPositionGroupBuyingPowerModel.cs.
|
virtual |
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.
parameters | An object containing the portfolio, the position group and the target signed buying power percentage |
Reimplemented from QuantConnect.Securities.Positions.PositionGroupBuyingPowerModel.
Definition at line 96 of file SecurityPositionGroupBuyingPowerModel.cs.
|
virtual |
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.
parameters | An object containing the portfolio, the position group and the delta buying power |
Used by the margin call model to reduce the position by a delta percent.
Reimplemented from QuantConnect.Securities.Positions.PositionGroupBuyingPowerModel.
Definition at line 124 of file SecurityPositionGroupBuyingPowerModel.cs.
|
virtual |
Check if there is sufficient buying power for the position group to execute this order.
parameters | An object containing the portfolio, the position group and the order |
Reimplemented from QuantConnect.Securities.Positions.PositionGroupBuyingPowerModel.
Definition at line 152 of file SecurityPositionGroupBuyingPowerModel.cs.
|
protectedvirtual |
Additionally check initial margin requirements if the algorithm only has default position groups
Reimplemented from QuantConnect.Securities.Positions.PositionGroupBuyingPowerModel.
Definition at line 173 of file SecurityPositionGroupBuyingPowerModel.cs.