Lean  $LEAN_TAG$
QuantConnect.Algorithm.Framework.Portfolio.PortfolioTargetCollection Class Reference

Provides a collection for managing IPortfolioTargets for each symbol More...

Inheritance diagram for QuantConnect.Algorithm.Framework.Portfolio.PortfolioTargetCollection:
[legend]

Public Member Functions

void Add (IPortfolioTarget target)
 Adds the specified target to the collection. If a target for the same symbol already exists it wil be overwritten. More...
 
void Add (KeyValuePair< Symbol, IPortfolioTarget > target)
 Adds the specified target to the collection. If a target for the same symbol already exists it wil be overwritten. More...
 
void Add (Symbol symbol, IPortfolioTarget target)
 Adds the specified target to the collection. If a target for the same symbol already exists it wil be overwritten. More...
 
void AddRange (IEnumerable< IPortfolioTarget > targets)
 Adds the specified targets to the collection. If a target for the same symbol already exists it will be overwritten. More...
 
void AddRange (IPortfolioTarget[] targets)
 Adds the specified targets to the collection. If a target for the same symbol already exists it will be overwritten. More...
 
void Clear ()
 Removes all portfolio targets from this collection More...
 
void ClearFulfilled (IAlgorithm algorithm)
 Removes fulfilled portfolio targets from this collection. Will only take into account actual holdings and ignore open orders. More...
 
bool Contains (IPortfolioTarget target)
 Determines whether or not the specified target exists in this collection. NOTE: This checks for the exact specified target, not by symbol. Use ContainsKey to check by symbol. More...
 
bool Contains (KeyValuePair< Symbol, IPortfolioTarget > target)
 Determines whether the specified symbol/target pair exists in this collection More...
 
bool ContainsKey (Symbol symbol)
 Determines whether the specified symbol exists as a key in this collection More...
 
void CopyTo (IPortfolioTarget[] array, int arrayIndex)
 Copies the targets in this collection to the specified array More...
 
void CopyTo (KeyValuePair< Symbol, IPortfolioTarget >[] array, int arrayIndex)
 Copies the targets in this collection to the specified array More...
 
bool Remove (Symbol symbol)
 Removes the target for the specified symbol if it exists in this collection. More...
 
bool Remove (KeyValuePair< Symbol, IPortfolioTarget > target)
 Removes the target for the specified symbol/target pair if it exists in this collection. More...
 
bool Remove (IPortfolioTarget target)
 Removes the target if it exists in this collection. More...
 
bool TryGetValue (Symbol symbol, out IPortfolioTarget target)
 Attempts to retrieve the target for the specified symbol More...
 
IEnumerator< IPortfolioTargetGetEnumerator ()
 Gets an enumerator to iterator over all portfolio targets in this collection. This is the default enumerator for this collection. More...
 
IEnumerable< IPortfolioTargetOrderByMarginImpact (IAlgorithm algorithm)
 Returned an ordered enumerable where position reducing orders are executed first and the remaining orders are executed in decreasing order value. Will NOT return targets for securities that have no data yet. Will NOT return targets for which current holdings + open orders quantity, sum up to the target quantity More...
 

Public Attributes

bool IsReadOnly => false
 Gets false. This collection is not read-only. More...
 

Properties

int Count [get]
 Gets the number of targets in this collection More...
 
bool IsEmpty [get]
 True if there is no target in the collection More...
 
ICollection< SymbolKeys [get]
 Gets the symbol keys for this collection More...
 
ICollection< IPortfolioTargetValues [get]
 Gets all portfolio targets in this collection Careful, will return targets for securities that might have no data yet. More...
 
IPortfolioTarget this[Symbol symbol] [get, set]
 Gets or sets the portfolio target for the specified symbol More...
 

Detailed Description

Provides a collection for managing IPortfolioTargets for each symbol

Definition at line 27 of file PortfolioTargetCollection.cs.

Member Function Documentation

◆ Add() [1/3]

void QuantConnect.Algorithm.Framework.Portfolio.PortfolioTargetCollection.Add ( IPortfolioTarget  target)

Adds the specified target to the collection. If a target for the same symbol already exists it wil be overwritten.

Parameters
targetThe portfolio target to add

Definition at line 105 of file PortfolioTargetCollection.cs.

Here is the caller graph for this function:

◆ Add() [2/3]

void QuantConnect.Algorithm.Framework.Portfolio.PortfolioTargetCollection.Add ( KeyValuePair< Symbol, IPortfolioTarget target)

Adds the specified target to the collection. If a target for the same symbol already exists it wil be overwritten.

Parameters
targetThe portfolio target to add

Definition at line 125 of file PortfolioTargetCollection.cs.

Here is the call graph for this function:

◆ Add() [3/3]

void QuantConnect.Algorithm.Framework.Portfolio.PortfolioTargetCollection.Add ( Symbol  symbol,
IPortfolioTarget  target 
)

Adds the specified target to the collection. If a target for the same symbol already exists it wil be overwritten.

Parameters
symbolThe symbol key
targetThe portfolio target to add

Definition at line 136 of file PortfolioTargetCollection.cs.

Here is the call graph for this function:

◆ AddRange() [1/2]

void QuantConnect.Algorithm.Framework.Portfolio.PortfolioTargetCollection.AddRange ( IEnumerable< IPortfolioTarget targets)

Adds the specified targets to the collection. If a target for the same symbol already exists it will be overwritten.

Parameters
targetsThe portfolio targets to add

Definition at line 146 of file PortfolioTargetCollection.cs.

Here is the caller graph for this function:

◆ AddRange() [2/2]

void QuantConnect.Algorithm.Framework.Portfolio.PortfolioTargetCollection.AddRange ( IPortfolioTarget[]  targets)

Adds the specified targets to the collection. If a target for the same symbol already exists it will be overwritten.

Parameters
targetsThe portfolio targets to add

Definition at line 164 of file PortfolioTargetCollection.cs.

Here is the call graph for this function:

◆ Clear()

void QuantConnect.Algorithm.Framework.Portfolio.PortfolioTargetCollection.Clear ( )

Removes all portfolio targets from this collection

Definition at line 172 of file PortfolioTargetCollection.cs.

◆ ClearFulfilled()

void QuantConnect.Algorithm.Framework.Portfolio.PortfolioTargetCollection.ClearFulfilled ( IAlgorithm  algorithm)

Removes fulfilled portfolio targets from this collection. Will only take into account actual holdings and ignore open orders.

Definition at line 186 of file PortfolioTargetCollection.cs.

Here is the call graph for this function:

◆ Contains() [1/2]

bool QuantConnect.Algorithm.Framework.Portfolio.PortfolioTargetCollection.Contains ( IPortfolioTarget  target)

Determines whether or not the specified target exists in this collection. NOTE: This checks for the exact specified target, not by symbol. Use ContainsKey to check by symbol.

Parameters
targetThe portfolio target to check for existence.
Returns
True if the target exists, false otherwise

Definition at line 207 of file PortfolioTargetCollection.cs.

Here is the caller graph for this function:

◆ Contains() [2/2]

bool QuantConnect.Algorithm.Framework.Portfolio.PortfolioTargetCollection.Contains ( KeyValuePair< Symbol, IPortfolioTarget target)

Determines whether the specified symbol/target pair exists in this collection

Parameters
targetThe symbol/target pair
Returns
True if the pair exists, false otherwise

Definition at line 225 of file PortfolioTargetCollection.cs.

Here is the call graph for this function:

◆ ContainsKey()

bool QuantConnect.Algorithm.Framework.Portfolio.PortfolioTargetCollection.ContainsKey ( Symbol  symbol)

Determines whether the specified symbol exists as a key in this collection

Parameters
symbolThe symbol key
Returns
True if the symbol exists in this collection, false otherwise

Definition at line 235 of file PortfolioTargetCollection.cs.

◆ CopyTo() [1/2]

void QuantConnect.Algorithm.Framework.Portfolio.PortfolioTargetCollection.CopyTo ( IPortfolioTarget[]  array,
int  arrayIndex 
)

Copies the targets in this collection to the specified array

Parameters
arrayThe destination array to copy to
arrayIndexThe index in the array to start copying to

Definition at line 248 of file PortfolioTargetCollection.cs.

◆ CopyTo() [2/2]

void QuantConnect.Algorithm.Framework.Portfolio.PortfolioTargetCollection.CopyTo ( KeyValuePair< Symbol, IPortfolioTarget >[]  array,
int  arrayIndex 
)

Copies the targets in this collection to the specified array

Parameters
arrayThe destination array to copy to
arrayIndexThe index in the array to start copying to

Definition at line 261 of file PortfolioTargetCollection.cs.

◆ Remove() [1/3]

bool QuantConnect.Algorithm.Framework.Portfolio.PortfolioTargetCollection.Remove ( Symbol  symbol)

Removes the target for the specified symbol if it exists in this collection.

Parameters
symbolThe symbol to remove
Returns
True if the symbol's target was removed, false if it doesn't exist in the collection

Definition at line 271 of file PortfolioTargetCollection.cs.

Here is the caller graph for this function:

◆ Remove() [2/3]

bool QuantConnect.Algorithm.Framework.Portfolio.PortfolioTargetCollection.Remove ( KeyValuePair< Symbol, IPortfolioTarget target)

Removes the target for the specified symbol/target pair if it exists in this collection.

Parameters
targetThe symbol/target pair to remove
Returns
True if the symbol's target was removed, false if it doesn't exist in the collection

Definition at line 290 of file PortfolioTargetCollection.cs.

Here is the call graph for this function:

◆ Remove() [3/3]

bool QuantConnect.Algorithm.Framework.Portfolio.PortfolioTargetCollection.Remove ( IPortfolioTarget  target)

Removes the target if it exists in this collection.

Parameters
targetThe target to remove
Returns
True if the target was removed, false if it doesn't exist in the collection

Definition at line 300 of file PortfolioTargetCollection.cs.

Here is the call graph for this function:

◆ TryGetValue()

bool QuantConnect.Algorithm.Framework.Portfolio.PortfolioTargetCollection.TryGetValue ( Symbol  symbol,
out IPortfolioTarget  target 
)

Attempts to retrieve the target for the specified symbol

Parameters
symbolThe symbol
targetThe portfolio target for the symbol, or null if not found
Returns
True if the symbol's target was found, false if it does not exist in this collection

Definition at line 329 of file PortfolioTargetCollection.cs.

◆ GetEnumerator()

IEnumerator<IPortfolioTarget> QuantConnect.Algorithm.Framework.Portfolio.PortfolioTargetCollection.GetEnumerator ( )

Gets an enumerator to iterator over all portfolio targets in this collection. This is the default enumerator for this collection.

Returns
Portfolio targets enumerator

Definition at line 384 of file PortfolioTargetCollection.cs.

◆ OrderByMarginImpact()

IEnumerable<IPortfolioTarget> QuantConnect.Algorithm.Framework.Portfolio.PortfolioTargetCollection.OrderByMarginImpact ( IAlgorithm  algorithm)

Returned an ordered enumerable where position reducing orders are executed first and the remaining orders are executed in decreasing order value. Will NOT return targets for securities that have no data yet. Will NOT return targets for which current holdings + open orders quantity, sum up to the target quantity

Parameters
algorithmThe algorithm instance

Definition at line 426 of file PortfolioTargetCollection.cs.

Member Data Documentation

◆ IsReadOnly

bool QuantConnect.Algorithm.Framework.Portfolio.PortfolioTargetCollection.IsReadOnly => false

Gets false. This collection is not read-only.

Definition at line 64 of file PortfolioTargetCollection.cs.

Property Documentation

◆ Count

int QuantConnect.Algorithm.Framework.Portfolio.PortfolioTargetCollection.Count
get

Gets the number of targets in this collection

Definition at line 37 of file PortfolioTargetCollection.cs.

◆ IsEmpty

bool QuantConnect.Algorithm.Framework.Portfolio.PortfolioTargetCollection.IsEmpty
get

True if there is no target in the collection

Definition at line 51 of file PortfolioTargetCollection.cs.

◆ Keys

ICollection<Symbol> QuantConnect.Algorithm.Framework.Portfolio.PortfolioTargetCollection.Keys
get

Gets the symbol keys for this collection

Definition at line 70 of file PortfolioTargetCollection.cs.

◆ Values

ICollection<IPortfolioTarget> QuantConnect.Algorithm.Framework.Portfolio.PortfolioTargetCollection.Values
get

Gets all portfolio targets in this collection Careful, will return targets for securities that might have no data yet.

Definition at line 85 of file PortfolioTargetCollection.cs.

◆ this[Symbol symbol]

IPortfolioTarget QuantConnect.Algorithm.Framework.Portfolio.PortfolioTargetCollection.this[Symbol symbol]
getset

Gets or sets the portfolio target for the specified symbol

Parameters
symbolThe symbol
Returns
The symbol's portfolio target if it exists in this collection, if not a KeyNotFoundException will be thrown.

Definition at line 343 of file PortfolioTargetCollection.cs.


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