CompositePositionGroupResolver
QuantConnect.Securities.Positions.CompositePositionGroupResolver
CompositePositionGroupResolver(
*resolvers: Union[
IPositionGroupResolver,
Iterable[IPositionGroupResolver],
]
)
CompositePositionGroupResolver(
resolvers: List[IPositionGroupResolver],
)
Bases: Object, IPositionGroupResolver
Provides an implementation of IPositionGroupResolver that invokes multiple wrapped implementations in succession. Each successive call to IPositionGroupresolver.resolve will receive the remaining positions that have yet to be grouped. Any non-grouped positions are placed into identity groups.
Initializes a new instance of the CompositePositionGroupResolver class
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resolvers
|
Union[IPositionGroupResolver, Iterable[IPositionGroupResolver]]
|
The position group resolvers to be invoked in order |
()
|
count
count: int
Gets the count of registered resolvers
add
add(resolver: IPositionGroupResolver) -> None
add(resolver: IPositionGroupResolver, index: int) -> None
Signature descriptions:
-
Adds the specified resolver to the end of the list of resolvers. This resolver will run last.
-
Inserts the specified resolver into the list of resolvers at the specified index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resolver
|
IPositionGroupResolver
|
The resolver to be added |
required |
index
|
Optional[int]
|
The zero based index indicating where to insert the resolver, zero inserts to the beginning |
None
|
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. |
remove
remove(resolver: IPositionGroupResolver) -> bool
Removes the specified resolver from the list of resolvers
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resolver
|
IPositionGroupResolver
|
The resolver to be removed |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the resolver was removed, false if it wasn't found in the list. |
resolve
resolve(
positions: PositionCollection,
) -> PositionGroupCollection
Resolves the optimal set of IPositionGroup from the provided positions. Implementations are required to deduct grouped positions from the positions collection.
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. |