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

Provides a collection type for IPositionGroup More...

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

Public Member Functions

 PositionGroupCollection (Dictionary< PositionGroupKey, IPositionGroup > groups, Dictionary< Symbol, HashSet< IPositionGroup >> groupsBySymbol)
 Initializes a new instance of the PositionGroupCollection class More...
 
 PositionGroupCollection (IReadOnlyCollection< IPositionGroup > groups)
 Initializes a new instance of the PositionGroupCollection class More...
 
PositionGroupCollection Add (IPositionGroup group)
 Creates a new PositionGroupCollection that contains all of the position groups in this collection in addition to the specified group . If a group with the same key already exists then it is overwritten. More...
 
bool Contains (PositionGroupKey key)
 Determines whether or not a group with the specified key exists in this collection More...
 
bool TryGetGroup (PositionGroupKey key, out IPositionGroup group)
 Attempts to retrieve the group with the specified key More...
 
bool TryGetGroups (Symbol symbol, out IReadOnlyCollection< IPositionGroup > groups)
 Attempts to retrieve all groups that contain the provided symbol More...
 
PositionGroupCollection CombineWith (PositionGroupCollection other)
 Merges this position group collection with the provided other collection. More...
 
IEnumerator< IPositionGroupGetEnumerator ()
 Returns an enumerator that iterates through the collection. More...
 

Public Attributes

int Count => _groups.Count
 Gets the number of positions in this group More...
 

Static Public Attributes

static PositionGroupCollection Empty => new(new Dictionary<PositionGroupKey, IPositionGroup>(), new Dictionary<Symbol, HashSet<IPositionGroup>>())
 Gets an empty instance of the PositionGroupCollection class More...
 

Properties

bool IsOnlyDefaultGroups [get]
 Gets whether or not this collection contains only default position groups More...
 
IPositionGroup this[PositionGroupKey key] [get]
 Gets the IPositionGroup matching the specified key. If one does not exist, then an empty group is returned matching the unit quantities defined in the key More...
 

Detailed Description

Provides a collection type for IPositionGroup

Definition at line 25 of file PositionGroupCollection.cs.

Constructor & Destructor Documentation

◆ PositionGroupCollection() [1/2]

QuantConnect.Securities.Positions.PositionGroupCollection.PositionGroupCollection ( Dictionary< PositionGroupKey, IPositionGroup groups,
Dictionary< Symbol, HashSet< IPositionGroup >>  groupsBySymbol 
)

Initializes a new instance of the PositionGroupCollection class

Parameters
groupsThe position groups keyed by their group key
groupsBySymbolThe position groups keyed by the symbol of each position

Definition at line 62 of file PositionGroupCollection.cs.

◆ PositionGroupCollection() [2/2]

QuantConnect.Securities.Positions.PositionGroupCollection.PositionGroupCollection ( IReadOnlyCollection< IPositionGroup groups)

Initializes a new instance of the PositionGroupCollection class

Parameters
groupsThe position groups

Definition at line 75 of file PositionGroupCollection.cs.

Here is the call graph for this function:

Member Function Documentation

◆ Add()

PositionGroupCollection QuantConnect.Securities.Positions.PositionGroupCollection.Add ( IPositionGroup  group)

Creates a new PositionGroupCollection that contains all of the position groups in this collection in addition to the specified group . If a group with the same key already exists then it is overwritten.

Definition at line 90 of file PositionGroupCollection.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Contains()

bool QuantConnect.Securities.Positions.PositionGroupCollection.Contains ( PositionGroupKey  key)

Determines whether or not a group with the specified key exists in this collection

Parameters
keyThe group key to search for
Returns
True if a group with the specified key was found, false otherwise

Definition at line 110 of file PositionGroupCollection.cs.

◆ TryGetGroup()

bool QuantConnect.Securities.Positions.PositionGroupCollection.TryGetGroup ( PositionGroupKey  key,
out IPositionGroup  group 
)

Attempts to retrieve the group with the specified key

Parameters
keyThe group key to search for
groupThe position group
Returns
True if group with key found, otherwise false

Definition at line 141 of file PositionGroupCollection.cs.

◆ TryGetGroups()

bool QuantConnect.Securities.Positions.PositionGroupCollection.TryGetGroups ( Symbol  symbol,
out IReadOnlyCollection< IPositionGroup groups 
)

Attempts to retrieve all groups that contain the provided symbol

Parameters
symbolThe symbol
groupsThe groups if any were found, otherwise null
Returns
True if groups were found for the specified symbol, otherwise false

Definition at line 152 of file PositionGroupCollection.cs.

◆ CombineWith()

PositionGroupCollection QuantConnect.Securities.Positions.PositionGroupCollection.CombineWith ( PositionGroupCollection  other)

Merges this position group collection with the provided other collection.

Definition at line 168 of file PositionGroupCollection.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetEnumerator()

IEnumerator<IPositionGroup> QuantConnect.Securities.Positions.PositionGroupCollection.GetEnumerator ( )

Returns an enumerator that iterates through the collection.

Returns
An enumerator that can be used to iterate through the collection.

Definition at line 190 of file PositionGroupCollection.cs.

Member Data Documentation

◆ Empty

PositionGroupCollection QuantConnect.Securities.Positions.PositionGroupCollection.Empty => new(new Dictionary<PositionGroupKey, IPositionGroup>(), new Dictionary<Symbol, HashSet<IPositionGroup>>())
static

Gets an empty instance of the PositionGroupCollection class

Definition at line 30 of file PositionGroupCollection.cs.

◆ Count

int QuantConnect.Securities.Positions.PositionGroupCollection.Count => _groups.Count

Gets the number of positions in this group

Definition at line 35 of file PositionGroupCollection.cs.

Property Documentation

◆ IsOnlyDefaultGroups

bool QuantConnect.Securities.Positions.PositionGroupCollection.IsOnlyDefaultGroups
get

Gets whether or not this collection contains only default position groups

Definition at line 41 of file PositionGroupCollection.cs.

◆ this[PositionGroupKey key]

IPositionGroup QuantConnect.Securities.Positions.PositionGroupCollection.this[PositionGroupKey key]
get

Gets the IPositionGroup matching the specified key. If one does not exist, then an empty group is returned matching the unit quantities defined in the key

Parameters
keyThe position group key to search for
Returns
The position group matching the specified key, or a new empty group if no matching group is found.

Definition at line 122 of file PositionGroupCollection.cs.


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