Skip to content

OptionStrategyPositionGroupResolver

QuantConnect.Securities.Positions.OptionStrategyPositionGroupResolver

OptionStrategyPositionGroupResolver(
    securities: SecurityManager,
)
OptionStrategyPositionGroupResolver(
    securities: SecurityManager,
    strategy_matcher_options: OptionStrategyMatcherOptions,
)

Bases: Object, IPositionGroupResolver

Class in charge of resolving option strategy groups which will use the OptionStrategyPositionGroupBuyingPowerModel

Signature descriptions:

  • Creates the default option strategy group resolver for OptionStrategyDefinitions.ALL_DEFINITIONS

  • Creates a custom option strategy group resolver

Parameters:

Name Type Description Default
strategy_matcher_options Optional[OptionStrategyMatcherOptions]

The option strategy matcher options instance to use

None
securities SecurityManager

The algorithms securities

required

get_impacted_groups

get_impacted_groups(
    groups: PositionGroupCollection,
    positions: Sequence[IPosition],
) -> Iterable[IPositionGroup]

Determines the position groups that would be evaluated for grouping of the specified positions were passed into the resolve method.

Parameters:

Name Type Description Default
groups PositionGroupCollection

The existing position groups

required
positions Sequence[IPosition]

The positions being changed

required

Returns:

Type Description
Iterable[IPositionGroup]

An enumerable containing the position groups that could be impacted by the specified position changes.

resolve

resolve(
    positions: PositionCollection,
) -> PositionGroupCollection

Resolves the position groups that exist within the specified collection of positions.

Parameters:

Name Type Description Default
positions PositionCollection

The collection of positions

required

Returns:

Type Description
PositionGroupCollection

An enumerable of position groups.

try_group

try_group(
    new_positions: Sequence[IPosition],
    current_positions: PositionGroupCollection,
    group: Optional[IPositionGroup],
) -> Tuple[bool, IPositionGroup]

Attempts to group the specified positions into a new IPositionGroup using an appropriate IPositionGroupBuyingPowerModel for position groups created via this resolver.

Parameters:

Name Type Description Default
new_positions Sequence[IPosition]

The positions to be grouped

required
current_positions PositionGroupCollection

The currently grouped positions

required
group Optional[IPositionGroup]

The grouped positions when this resolver is able to, otherwise null

required

Returns:

Type Description
Tuple[bool, IPositionGroup]

True if this resolver can group the specified positions, otherwise false.