Lean  $LEAN_TAG$
QuantConnect.Securities.Positions.CompositePositionGroupResolver Class Reference

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. More...

Inheritance diagram for QuantConnect.Securities.Positions.CompositePositionGroupResolver:
[legend]

Public Member Functions

 CompositePositionGroupResolver (params IPositionGroupResolver[] resolvers)
 Initializes a new instance of the CompositePositionGroupResolver class More...
 
 CompositePositionGroupResolver (IEnumerable< IPositionGroupResolver > resolvers)
 Initializes a new instance of the CompositePositionGroupResolver class More...
 
void Add (IPositionGroupResolver resolver)
 Adds the specified resolver to the end of the list of resolvers. This resolver will run last. More...
 
void Add (IPositionGroupResolver resolver, int index)
 Inserts the specified resolver into the list of resolvers at the specified index. More...
 
bool Remove (IPositionGroupResolver resolver)
 Removes the specified resolver from the list of resolvers More...
 
PositionGroupCollection Resolve (PositionCollection positions)
 Resolves the optimal set of IPositionGroup from the provided positions . Implementations are required to deduct grouped positions from the positions collection. More...
 
bool TryGroup (IReadOnlyCollection< IPosition > newPositions, PositionGroupCollection currentPositions, out IPositionGroup group)
 Attempts to group the specified positions into a new IPositionGroup using an appropriate IPositionGroupBuyingPowerModel for position groups created via this resolver. More...
 
IEnumerable< IPositionGroupGetImpactedGroups (PositionGroupCollection groups, IReadOnlyCollection< IPosition > positions)
 Determines the position groups that would be evaluated for grouping of the specified positions were passed into the Resolve method. More...
 

Public Attributes

int Count => _resolvers.Count
 Gets the count of registered resolvers More...
 

Detailed Description

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.

Definition at line 27 of file CompositePositionGroupResolver.cs.

Constructor & Destructor Documentation

◆ CompositePositionGroupResolver() [1/2]

QuantConnect.Securities.Positions.CompositePositionGroupResolver.CompositePositionGroupResolver ( params IPositionGroupResolver[]  resolvers)

Initializes a new instance of the CompositePositionGroupResolver class

Parameters
resolversThe position group resolvers to be invoked in order

Definition at line 40 of file CompositePositionGroupResolver.cs.

◆ CompositePositionGroupResolver() [2/2]

QuantConnect.Securities.Positions.CompositePositionGroupResolver.CompositePositionGroupResolver ( IEnumerable< IPositionGroupResolver resolvers)

Initializes a new instance of the CompositePositionGroupResolver class

Parameters
resolversThe position group resolvers to be invoked in order

Definition at line 49 of file CompositePositionGroupResolver.cs.

Member Function Documentation

◆ Add() [1/2]

void QuantConnect.Securities.Positions.CompositePositionGroupResolver.Add ( IPositionGroupResolver  resolver)

Adds the specified resolver to the end of the list of resolvers. This resolver will run last.

Parameters
resolverThe resolver to be added

Definition at line 58 of file CompositePositionGroupResolver.cs.

◆ Add() [2/2]

void QuantConnect.Securities.Positions.CompositePositionGroupResolver.Add ( IPositionGroupResolver  resolver,
int  index 
)

Inserts the specified resolver into the list of resolvers at the specified index.

Parameters
resolverThe resolver to be inserted
indexThe zero based index indicating where to insert the resolver, zero inserts to the beginning of the list making this resolver un first and Count inserts the resolver to the end of the list making this resolver run last

Definition at line 70 of file CompositePositionGroupResolver.cs.

◆ Remove()

bool QuantConnect.Securities.Positions.CompositePositionGroupResolver.Remove ( IPositionGroupResolver  resolver)

Removes the specified resolver from the list of resolvers

Parameters
resolverThe resolver to be removed
Returns
True if the resolver was removed, false if it wasn't found in the list

Definition at line 81 of file CompositePositionGroupResolver.cs.

◆ Resolve()

PositionGroupCollection QuantConnect.Securities.Positions.CompositePositionGroupResolver.Resolve ( PositionCollection  positions)

Resolves the optimal set of IPositionGroup from the provided positions . Implementations are required to deduct grouped positions from the positions collection.

Implements QuantConnect.Securities.Positions.IPositionGroupResolver.

Definition at line 90 of file CompositePositionGroupResolver.cs.

Here is the call graph for this function:

◆ TryGroup()

bool QuantConnect.Securities.Positions.CompositePositionGroupResolver.TryGroup ( IReadOnlyCollection< IPosition newPositions,
PositionGroupCollection  currentPositions,
out IPositionGroup  group 
)

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

Parameters
newPositionsThe positions to be grouped
currentPositionsThe currently grouped positions
groupThe grouped positions when this resolver is able to, otherwise null
Returns
True if this resolver can group the specified positions, otherwise false

Implements QuantConnect.Securities.Positions.IPositionGroupResolver.

Definition at line 119 of file CompositePositionGroupResolver.cs.

◆ GetImpactedGroups()

IEnumerable<IPositionGroup> QuantConnect.Securities.Positions.CompositePositionGroupResolver.GetImpactedGroups ( PositionGroupCollection  groups,
IReadOnlyCollection< IPosition positions 
)

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

This function allows us to determine a set of impacted groups and run the resolver on just those groups in order to support what-if analysis

Parameters
groupsThe existing position groups
positionsThe positions being changed
Returns
An enumerable containing the position groups that could be impacted by the specified position changes

Implements QuantConnect.Securities.Positions.IPositionGroupResolver.

Definition at line 144 of file CompositePositionGroupResolver.cs.

Member Data Documentation

◆ Count

int QuantConnect.Securities.Positions.CompositePositionGroupResolver.Count => _resolvers.Count

Gets the count of registered resolvers

Definition at line 32 of file CompositePositionGroupResolver.cs.


The documentation for this class was generated from the following file: