Lean  $LEAN_TAG$
QuantConnect.Securities.SecurityPortfolioManager Class Reference

Portfolio manager class groups popular properties and makes them accessible through one interface. It also provide indexing by the vehicle symbol to get the Security.Holding objects. More...

Inheritance diagram for QuantConnect.Securities.SecurityPortfolioManager:
[legend]

Public Member Functions

 SecurityPortfolioManager (SecurityManager securityManager, SecurityTransactionManager transactions, IAlgorithmSettings algorithmSettings, IOrderProperties defaultOrderProperties=null)
 Initialise security portfolio manager. More...
 
void Add (Symbol symbol, SecurityHolding holding)
 Add a new securities string-security to the portfolio. More...
 
void Add (KeyValuePair< Symbol, SecurityHolding > pair)
 Add a new securities key value pair to the portfolio. More...
 
override void Clear ()
 Clear the portfolio of securities objects. More...
 
bool Remove (KeyValuePair< Symbol, SecurityHolding > pair)
 Remove this keyvalue pair from the portfolio. More...
 
override bool Remove (Symbol symbol)
 Remove this symbol from the portfolio. More...
 
bool ContainsKey (Symbol symbol)
 Check if the portfolio contains this symbol string. More...
 
bool Contains (KeyValuePair< Symbol, SecurityHolding > pair)
 Check if the key-value pair is in the portfolio. More...
 
void CopyTo (KeyValuePair< Symbol, SecurityHolding >[] array, int index)
 Copy contents of the portfolio collection to a new destination. More...
 
override bool TryGetValue (Symbol symbol, out SecurityHolding holding)
 Attempt to get the value of the securities holding class if this symbol exists. More...
 
void InvalidateTotalPortfolioValue ()
 Will flag the current TotalPortfolioValue as invalid so it is recalculated when gotten More...
 
decimal GetMarginRemaining (decimal totalPortfolioValue)
 Gets the remaining margin on the account in the account's currency for the given total portfolio value More...
 
void SetAccountCurrency (string accountCurrency, decimal? startingCash=null)
 Sets the account currency cash symbol this algorithm is to manage, as well as the starting cash in this currency if given More...
 
void SetCash (decimal cash)
 Set the account currency cash this algorithm is to manage. More...
 
void SetCash (string symbol, decimal cash, decimal conversionRate)
 Set the cash for the specified symbol More...
 
decimal GetMarginRemaining (Symbol symbol, OrderDirection direction=OrderDirection.Buy)
 Gets the margin available for trading a specific symbol in a specific direction. More...
 
decimal GetBuyingPower (Symbol symbol, OrderDirection direction=OrderDirection.Buy)
 Gets the margin available for trading a specific symbol in a specific direction. Alias for GetMarginRemaining(Symbol, OrderDirection) More...
 
virtual void ProcessFills (List< OrderEvent > fills)
 Calculate the new average price after processing a list of partial/complete order fill events. More...
 
void ApplyDividend (Dividend dividend, bool liveMode, DataNormalizationMode mode)
 Applies a dividend to the portfolio More...
 
void ApplySplit (Split split, Security security, bool liveMode, DataNormalizationMode mode)
 Applies a split to the portfolio More...
 
void AddTransactionRecord (DateTime time, decimal transactionProfitLoss, bool isWin)
 Record the transaction value and time in a list to later be processed for statistics creation. More...
 
void LogMarginInformation (OrderRequest orderRequest=null)
 Logs margin information for debugging More...
 
void SetMarginCallModel (IMarginCallModel marginCallModel)
 Sets the margin call model More...
 
void SetMarginCallModel (PyObject pyObject)
 Sets the margin call model More...
 
HasSufficientBuyingPowerForOrderResult HasSufficientBuyingPowerForOrder (List< Order > orders)
 Will determine if the algorithms portfolio has enough buying power to fill the given orders More...
 
void SetPositions (SecurityPositionGroupModel positionGroupModel)
 Will set the security position group model to use More...
 
- Public Member Functions inherited from QuantConnect.ExtendedDictionary< SecurityHolding >
abstract bool TryGetValue (Symbol symbol, out T value)
 Gets the value associated with the specified Symbol. More...
 
void clear ()
 Removes all keys and values from the IExtendedDictionary<TKey, TValue>. More...
 
PyDict copy ()
 Creates a shallow copy of the IExtendedDictionary<TKey, TValue>. More...
 
PyDict fromkeys (Symbol[] sequence)
 Creates a new dictionary from the given sequence of elements. More...
 
PyDict fromkeys (Symbol[] sequence, T value)
 Creates a new dictionary from the given sequence of elements with a value provided by the user. More...
 
get (Symbol symbol)
 Returns the value for the specified Symbol if Symbol is in dictionary. More...
 
get (Symbol symbol, T value)
 Returns the value for the specified Symbol if Symbol is in dictionary. More...
 
PyList items ()
 Returns a view object that displays a list of dictionary's (Symbol, value) tuple pairs. More...
 
PyTuple popitem ()
 Returns and removes an arbitrary element (Symbol, value) pair from the dictionary. More...
 
setdefault (Symbol symbol)
 Returns the value of a Symbol (if the Symbol is in dictionary). If not, it inserts Symbol with a value to the dictionary. More...
 
setdefault (Symbol symbol, T default_value)
 Returns the value of a Symbol (if the Symbol is in dictionary). If not, it inserts Symbol with a value to the dictionary. More...
 
pop (Symbol symbol)
 Removes and returns an element from a dictionary having the given Symbol. More...
 
pop (Symbol symbol, T default_value)
 Removes and returns an element from a dictionary having the given Symbol. More...
 
void update (PyObject other)
 Updates the dictionary with the elements from the another dictionary object or from an iterable of Symbol/value pairs. The update() method adds element(s) to the dictionary if the Symbol is not in the dictionary.If the Symbol is in the dictionary, it updates the Symbol with the new value. More...
 
PyList keys ()
 Returns a view object that displays a list of all the Symbol objects in the dictionary More...
 
PyList values ()
 Returns a view object that displays a list of all the values in the dictionary. More...
 

Public Attributes

SecurityManager Securities
 Local access to the securities collection for the portfolio summation. More...
 
SecurityTransactionManager Transactions
 Local access to the transactions collection for the portfolio summation and updates. More...
 
bool Invested => HoldStock
 Alias for HoldStock. Check if we have any holdings. More...
 
decimal MarginRemaining => GetMarginRemaining(TotalPortfolioValue)
 Gets the remaining margin on the account in the account's currency More...
 
- Public Attributes inherited from QuantConnect.ExtendedDictionary< SecurityHolding >
virtual bool IsReadOnly
 Gets a value indicating whether the IDictionary object is read-only. More...
 

Protected Attributes

override IEnumerable< SymbolGetKeys => Keys
 Gets an T:System.Collections.Generic.ICollection`1 containing the Symbol objects of the T:System.Collections.Generic.IDictionary`2. More...
 
override IEnumerable< SecurityHoldingGetValues => Securities.Select(pair => pair.Value.Holdings)
 Gets an T:System.Collections.Generic.ICollection`1 containing the values in the T:System.Collections.Generic.IDictionary`2. More...
 

Properties

SecurityPositionGroupModelPositions [get, set]
 Local access to the position manager More...
 
CashBook CashBook [get]
 Gets the cash book that keeps track of all currency holdings (only settled cash) More...
 
CashBook UnsettledCashBook [get]
 Gets the cash book that keeps track of all currency holdings (only unsettled cash) More...
 
int Count [get]
 Count the securities objects in the portfolio. More...
 
override bool IsReadOnly [get]
 Check if the underlying securities array is read only. More...
 
ICollection< SymbolKeys [get]
 Symbol keys collection of the underlying assets in the portfolio. More...
 
ICollection< SecurityHoldingValues [get]
 Collection of securities objects in the portfolio. More...
 
decimal Cash [get]
 Sum of all currencies in account in US dollars (only settled cash) More...
 
decimal UnsettledCash [get]
 Sum of all currencies in account in US dollars (only unsettled cash) More...
 
decimal TotalUnleveredAbsoluteHoldingsCost [get]
 Absolute value of cash discounted from our total cash by the holdings we own. More...
 
decimal TotalAbsoluteHoldingsCost [get]
 Gets the total absolute holdings cost of the portfolio. This sums up the individual absolute cost of each holding More...
 
decimal TotalHoldingsValue [get]
 Absolute sum the individual items in portfolio. More...
 
bool HoldStock [get]
 Boolean flag indicating we have any holdings in the portfolio. More...
 
decimal TotalUnrealisedProfit [get]
 Get the total unrealised profit in our portfolio from the individual security unrealized profits. More...
 
decimal TotalUnrealizedProfit [get]
 Get the total unrealised profit in our portfolio from the individual security unrealized profits. More...
 
decimal TotalPortfolioValue [get]
 Total portfolio value if we sold all holdings at current market rates. More...
 
decimal TotalPortfolioValueLessFreeBuffer [get]
 Returns the adjusted total portfolio value removing the free amount If the IAlgorithmSettings.FreePortfolioValue has not been set, the free amount will have a trailing behavior and be updated when requested More...
 
decimal TotalFees [get]
 Total fees paid during the algorithm operation across all securities in portfolio. More...
 
decimal TotalProfit [get]
 Sum of all gross profit across all securities in portfolio and dividend payments. More...
 
decimal TotalNetProfit [get]
 Sum of all net profit across all securities in portfolio and dividend payments. More...
 
decimal TotalSaleVolume [get]
 Total sale volume since the start of algorithm operations. More...
 
decimal TotalMarginUsed [get]
 Gets the total margin used across all securities in the account's currency More...
 
IMarginCallModel MarginCallModel [get, set]
 Gets or sets the MarginCallModel for the portfolio. This is used to executed margin call orders. More...
 
override SecurityHolding this[Symbol symbol] [get, set]
 Indexer for the PortfolioManager class to access the underlying security holdings objects. More...
 
- Properties inherited from QuantConnect.ExtendedDictionary< SecurityHolding >
abstract IEnumerable< SymbolGetKeys [get]
 Gets an T:System.Collections.Generic.ICollection`1 containing the Symbol objects of the T:System.Collections.Generic.IDictionary`2. More...
 
abstract IEnumerable< T > GetValues [get]
 Gets an T:System.Collections.Generic.ICollection`1 containing the values in the T:System.Collections.Generic.IDictionary`2. More...
 
virtual T this[Symbol symbol] [get, set]
 Indexer method for the base dictioanry to access the objects by their symbol. More...
 
virtual T this[string ticker] [get, set]
 Indexer method for the base dictioanry to access the objects by their symbol. More...
 

Detailed Description

Portfolio manager class groups popular properties and makes them accessible through one interface. It also provide indexing by the vehicle symbol to get the Security.Holding objects.

Definition at line 35 of file SecurityPortfolioManager.cs.

Constructor & Destructor Documentation

◆ SecurityPortfolioManager()

QuantConnect.Securities.SecurityPortfolioManager.SecurityPortfolioManager ( SecurityManager  securityManager,
SecurityTransactionManager  transactions,
IAlgorithmSettings  algorithmSettings,
IOrderProperties  defaultOrderProperties = null 
)

Initialise security portfolio manager.

Definition at line 86 of file SecurityPortfolioManager.cs.

Here is the call graph for this function:

Member Function Documentation

◆ Add() [1/2]

void QuantConnect.Securities.SecurityPortfolioManager.Add ( Symbol  symbol,
SecurityHolding  holding 
)

Add a new securities string-security to the portfolio.

Parameters
symbolSymbol of dictionary
holdingSecurityHoldings object
Exceptions
NotImplementedExceptionPortfolio object is an adaptor for Security Manager. This method is not applicable for PortfolioManager class.

This method is not implemented and using it will throw an exception

Definition at line 134 of file SecurityPortfolioManager.cs.

◆ Add() [2/2]

void QuantConnect.Securities.SecurityPortfolioManager.Add ( KeyValuePair< Symbol, SecurityHolding pair)

Add a new securities key value pair to the portfolio.

Parameters
pairKey value pair of dictionary
Exceptions
NotImplementedExceptionPortfolio object is an adaptor for Security Manager. This method is not applicable for PortfolioManager class.

This method is not implemented and using it will throw an exception

Definition at line 142 of file SecurityPortfolioManager.cs.

◆ Clear()

override void QuantConnect.Securities.SecurityPortfolioManager.Clear ( )
virtual

Clear the portfolio of securities objects.

Exceptions
NotImplementedExceptionPortfolio object is an adaptor for Security Manager. This method is not applicable for PortfolioManager class.

This method is not implemented and using it will throw an exception

Reimplemented from QuantConnect.ExtendedDictionary< SecurityHolding >.

Definition at line 149 of file SecurityPortfolioManager.cs.

◆ Remove() [1/2]

bool QuantConnect.Securities.SecurityPortfolioManager.Remove ( KeyValuePair< Symbol, SecurityHolding pair)

Remove this keyvalue pair from the portfolio.

Exceptions
NotImplementedExceptionPortfolio object is an adaptor for Security Manager. This method is not applicable for PortfolioManager class.
Parameters
pairKey value pair of dictionary

This method is not implemented and using it will throw an exception

Definition at line 157 of file SecurityPortfolioManager.cs.

◆ Remove() [2/2]

override bool QuantConnect.Securities.SecurityPortfolioManager.Remove ( Symbol  symbol)
virtual

Remove this symbol from the portfolio.

Exceptions
NotImplementedExceptionPortfolio object is an adaptor for Security Manager. This method is not applicable for PortfolioManager class.
Parameters
symbolSymbol of dictionary

This method is not implemented and using it will throw an exception

Reimplemented from QuantConnect.ExtendedDictionary< SecurityHolding >.

Definition at line 165 of file SecurityPortfolioManager.cs.

◆ ContainsKey()

bool QuantConnect.Securities.SecurityPortfolioManager.ContainsKey ( Symbol  symbol)

Check if the portfolio contains this symbol string.

Parameters
symbolString search symbol for the security
Returns
Boolean true if portfolio contains this symbol

Definition at line 172 of file SecurityPortfolioManager.cs.

Here is the call graph for this function:

◆ Contains()

bool QuantConnect.Securities.SecurityPortfolioManager.Contains ( KeyValuePair< Symbol, SecurityHolding pair)

Check if the key-value pair is in the portfolio.

IDictionary implementation calling the underlying Securities collection

Parameters
pairPair we're searching for
Returns
True if we have this object

Definition at line 183 of file SecurityPortfolioManager.cs.

Here is the call graph for this function:

◆ CopyTo()

void QuantConnect.Securities.SecurityPortfolioManager.CopyTo ( KeyValuePair< Symbol, SecurityHolding >[]  array,
int  index 
)

Copy contents of the portfolio collection to a new destination.

IDictionary implementation calling the underlying Securities collection

Parameters
arrayDestination array
indexPosition in array to start copying

Definition at line 218 of file SecurityPortfolioManager.cs.

◆ TryGetValue()

override bool QuantConnect.Securities.SecurityPortfolioManager.TryGetValue ( Symbol  symbol,
out SecurityHolding  holding 
)

Attempt to get the value of the securities holding class if this symbol exists.

Parameters
symbolString search symbol
holdingHoldings object of this security

IDictionary implementation

Returns
Boolean true if successful locating and setting the holdings object

Definition at line 279 of file SecurityPortfolioManager.cs.

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

◆ InvalidateTotalPortfolioValue()

void QuantConnect.Securities.SecurityPortfolioManager.InvalidateTotalPortfolioValue ( )

Will flag the current TotalPortfolioValue as invalid so it is recalculated when gotten

Definition at line 502 of file SecurityPortfolioManager.cs.

Here is the caller graph for this function:

◆ GetMarginRemaining() [1/2]

decimal QuantConnect.Securities.SecurityPortfolioManager.GetMarginRemaining ( decimal  totalPortfolioValue)

Gets the remaining margin on the account in the account's currency for the given total portfolio value

This method is for performance, for when the user already knows the total portfolio value, we can avoid re calculating it. Else use MarginRemaining

Parameters
totalPortfolioValueThe total portfolio value TotalPortfolioValue

Definition at line 582 of file SecurityPortfolioManager.cs.

Here is the caller graph for this function:

◆ SetAccountCurrency()

void QuantConnect.Securities.SecurityPortfolioManager.SetAccountCurrency ( string  accountCurrency,
decimal?  startingCash = null 
)

Sets the account currency cash symbol this algorithm is to manage, as well as the starting cash in this currency if given

Has to be called before calling SetCash(decimal) or adding any Security

Parameters
accountCurrencyThe account currency cash symbol to set
startingCashThe account currency starting cash to set

Definition at line 612 of file SecurityPortfolioManager.cs.

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

◆ SetCash() [1/2]

void QuantConnect.Securities.SecurityPortfolioManager.SetCash ( decimal  cash)

Set the account currency cash this algorithm is to manage.

Parameters
cashDecimal cash value of portfolio

Definition at line 659 of file SecurityPortfolioManager.cs.

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

◆ SetCash() [2/2]

void QuantConnect.Securities.SecurityPortfolioManager.SetCash ( string  symbol,
decimal  cash,
decimal  conversionRate 
)

Set the cash for the specified symbol

Parameters
symbolThe cash symbol to set
cashDecimal cash value of portfolio
conversionRateThe current conversion rate for the

Definition at line 671 of file SecurityPortfolioManager.cs.

Here is the call graph for this function:

◆ GetMarginRemaining() [2/2]

decimal QuantConnect.Securities.SecurityPortfolioManager.GetMarginRemaining ( Symbol  symbol,
OrderDirection  direction = OrderDirection.Buy 
)

Gets the margin available for trading a specific symbol in a specific direction.

Parameters
symbolThe symbol to compute margin remaining for
directionThe order/trading direction
Returns
The maximum order size that is currently executable in the specified direction

Definition at line 694 of file SecurityPortfolioManager.cs.

Here is the call graph for this function:

◆ GetBuyingPower()

decimal QuantConnect.Securities.SecurityPortfolioManager.GetBuyingPower ( Symbol  symbol,
OrderDirection  direction = OrderDirection.Buy 
)

Gets the margin available for trading a specific symbol in a specific direction. Alias for GetMarginRemaining(Symbol, OrderDirection)

Parameters
symbolThe symbol to compute margin remaining for
directionThe order/trading direction
Returns
The maximum order size that is currently executable in the specified direction

Definition at line 719 of file SecurityPortfolioManager.cs.

Here is the call graph for this function:

◆ ProcessFills()

virtual void QuantConnect.Securities.SecurityPortfolioManager.ProcessFills ( List< OrderEvent fills)
virtual

Calculate the new average price after processing a list of partial/complete order fill events.

For purchasing stocks from zero holdings, the new average price is the sale price. When simply partially reducing holdings the average price remains the same. When crossing zero holdings the average price becomes the trade price in the new side of zero.

Definition at line 732 of file SecurityPortfolioManager.cs.

Here is the call graph for this function:

◆ ApplyDividend()

void QuantConnect.Securities.SecurityPortfolioManager.ApplyDividend ( Dividend  dividend,
bool  liveMode,
DataNormalizationMode  mode 
)

Applies a dividend to the portfolio

Parameters
dividendThe dividend to be applied
liveModeTrue if live mode, false for backtest
modeThe DataNormalizationMode for this security

Definition at line 754 of file SecurityPortfolioManager.cs.

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

◆ ApplySplit()

void QuantConnect.Securities.SecurityPortfolioManager.ApplySplit ( Split  split,
Security  security,
bool  liveMode,
DataNormalizationMode  mode 
)

Applies a split to the portfolio

Parameters
splitThe split to be applied
securityThe security the split will be applied to
liveModeTrue if live mode, false for backtest
modeThe DataNormalizationMode for this security

Definition at line 784 of file SecurityPortfolioManager.cs.

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

◆ AddTransactionRecord()

void QuantConnect.Securities.SecurityPortfolioManager.AddTransactionRecord ( DateTime  time,
decimal  transactionProfitLoss,
bool  isWin 
)

Record the transaction value and time in a list to later be processed for statistics creation.

Parameters
timeTime of order processed
transactionProfitLossProfit Loss.
isWinWhether the transaction is a win. For options exercise, this might not depend only on the profit/loss value

Definition at line 853 of file SecurityPortfolioManager.cs.

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

◆ LogMarginInformation()

void QuantConnect.Securities.SecurityPortfolioManager.LogMarginInformation ( OrderRequest  orderRequest = null)

Logs margin information for debugging

Definition at line 878 of file SecurityPortfolioManager.cs.

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

◆ SetMarginCallModel() [1/2]

void QuantConnect.Securities.SecurityPortfolioManager.SetMarginCallModel ( IMarginCallModel  marginCallModel)

Sets the margin call model

Parameters
marginCallModelModel that represents a portfolio's model to executed margin call orders.

Definition at line 905 of file SecurityPortfolioManager.cs.

Here is the caller graph for this function:

◆ SetMarginCallModel() [2/2]

void QuantConnect.Securities.SecurityPortfolioManager.SetMarginCallModel ( PyObject  pyObject)

Sets the margin call model

Parameters
pyObjectModel that represents a portfolio's model to executed margin call orders.

Definition at line 914 of file SecurityPortfolioManager.cs.

Here is the call graph for this function:

◆ HasSufficientBuyingPowerForOrder()

HasSufficientBuyingPowerForOrderResult QuantConnect.Securities.SecurityPortfolioManager.HasSufficientBuyingPowerForOrder ( List< Order orders)

Will determine if the algorithms portfolio has enough buying power to fill the given orders

Parameters
ordersThe orders to check
Returns
True if the algorithm has enough buying power available

Definition at line 924 of file SecurityPortfolioManager.cs.

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

◆ SetPositions()

void QuantConnect.Securities.SecurityPortfolioManager.SetPositions ( SecurityPositionGroupModel  positionGroupModel)

Will set the security position group model to use

Parameters
positionGroupModelThe position group model instance

Definition at line 949 of file SecurityPortfolioManager.cs.

Member Data Documentation

◆ Securities

SecurityManager QuantConnect.Securities.SecurityPortfolioManager.Securities

Local access to the securities collection for the portfolio summation.

Definition at line 50 of file SecurityPortfolioManager.cs.

◆ Transactions

SecurityTransactionManager QuantConnect.Securities.SecurityPortfolioManager.Transactions

Local access to the transactions collection for the portfolio summation and updates.

Definition at line 55 of file SecurityPortfolioManager.cs.

◆ GetKeys

override IEnumerable<Symbol> QuantConnect.Securities.SecurityPortfolioManager.GetKeys => Keys
protected

Gets an T:System.Collections.Generic.ICollection`1 containing the Symbol objects of the T:System.Collections.Generic.IDictionary`2.

Returns
An T:System.Collections.Generic.ICollection`1 containing the Symbol objects of the object that implements T:System.Collections.Generic.IDictionary`2.

Definition at line 238 of file SecurityPortfolioManager.cs.

◆ GetValues

override IEnumerable<SecurityHolding> QuantConnect.Securities.SecurityPortfolioManager.GetValues => Securities.Select(pair => pair.Value.Holdings)
protected

Gets an T:System.Collections.Generic.ICollection`1 containing the values in the T:System.Collections.Generic.IDictionary`2.

Returns
An T:System.Collections.Generic.ICollection`1 containing the values in the object that implements T:System.Collections.Generic.IDictionary`2.

Definition at line 246 of file SecurityPortfolioManager.cs.

◆ Invested

bool QuantConnect.Securities.SecurityPortfolioManager.Invested => HoldStock

Alias for HoldStock. Check if we have any holdings.

See also
HoldStock

Definition at line 393 of file SecurityPortfolioManager.cs.

◆ MarginRemaining

decimal QuantConnect.Securities.SecurityPortfolioManager.MarginRemaining => GetMarginRemaining(TotalPortfolioValue)

Gets the remaining margin on the account in the account's currency

GetMarginRemaining(decimal)

Definition at line 572 of file SecurityPortfolioManager.cs.

Property Documentation

◆ Positions

SecurityPositionGroupModel? QuantConnect.Securities.SecurityPortfolioManager.Positions
getset

Local access to the position manager

Definition at line 61 of file SecurityPortfolioManager.cs.

◆ CashBook

CashBook QuantConnect.Securities.SecurityPortfolioManager.CashBook
get

Gets the cash book that keeps track of all currency holdings (only settled cash)

Definition at line 76 of file SecurityPortfolioManager.cs.

◆ UnsettledCashBook

CashBook QuantConnect.Securities.SecurityPortfolioManager.UnsettledCashBook
get

Gets the cash book that keeps track of all currency holdings (only unsettled cash)

Definition at line 81 of file SecurityPortfolioManager.cs.

◆ Count

int QuantConnect.Securities.SecurityPortfolioManager.Count
get

Count the securities objects in the portfolio.

IDictionary implementation calling the underlying Securities collection

Definition at line 193 of file SecurityPortfolioManager.cs.

◆ IsReadOnly

override bool QuantConnect.Securities.SecurityPortfolioManager.IsReadOnly
get

Check if the underlying securities array is read only.

IDictionary implementation calling the underlying Securities collection

Definition at line 205 of file SecurityPortfolioManager.cs.

◆ Keys

ICollection<Symbol> QuantConnect.Securities.SecurityPortfolioManager.Keys
get

Symbol keys collection of the underlying assets in the portfolio.

IDictionary implementation calling the underlying securities key symbols

Definition at line 253 of file SecurityPortfolioManager.cs.

◆ Values

ICollection<SecurityHolding> QuantConnect.Securities.SecurityPortfolioManager.Values
get

Collection of securities objects in the portfolio.

IDictionary implementation calling the underlying securities values collection

Definition at line 265 of file SecurityPortfolioManager.cs.

◆ Cash

decimal QuantConnect.Securities.SecurityPortfolioManager.Cash
get

Sum of all currencies in account in US dollars (only settled cash)

This should not be mistaken for margin available because Forex uses margin even though the total cash value is not impact

Definition at line 317 of file SecurityPortfolioManager.cs.

◆ UnsettledCash

decimal QuantConnect.Securities.SecurityPortfolioManager.UnsettledCash
get

Sum of all currencies in account in US dollars (only unsettled cash)

This should not be mistaken for margin available because Forex uses margin even though the total cash value is not impact

Definition at line 329 of file SecurityPortfolioManager.cs.

◆ TotalUnleveredAbsoluteHoldingsCost

decimal QuantConnect.Securities.SecurityPortfolioManager.TotalUnleveredAbsoluteHoldingsCost
get

Absolute value of cash discounted from our total cash by the holdings we own.

When account has leverage the actual cash removed is a fraction of the purchase price according to the leverage

Definition at line 338 of file SecurityPortfolioManager.cs.

◆ TotalAbsoluteHoldingsCost

decimal QuantConnect.Securities.SecurityPortfolioManager.TotalAbsoluteHoldingsCost
get

Gets the total absolute holdings cost of the portfolio. This sums up the individual absolute cost of each holding

Definition at line 350 of file SecurityPortfolioManager.cs.

◆ TotalHoldingsValue

decimal QuantConnect.Securities.SecurityPortfolioManager.TotalHoldingsValue
get

Absolute sum the individual items in portfolio.

Definition at line 361 of file SecurityPortfolioManager.cs.

◆ HoldStock

bool QuantConnect.Securities.SecurityPortfolioManager.HoldStock
get

Boolean flag indicating we have any holdings in the portfolio.

Assumes no asset can have $0 price and uses the sum of total holdings value

See also
Invested

Definition at line 375 of file SecurityPortfolioManager.cs.

◆ TotalUnrealisedProfit

decimal QuantConnect.Securities.SecurityPortfolioManager.TotalUnrealisedProfit
get

Get the total unrealised profit in our portfolio from the individual security unrealized profits.

Definition at line 399 of file SecurityPortfolioManager.cs.

◆ TotalUnrealizedProfit

decimal QuantConnect.Securities.SecurityPortfolioManager.TotalUnrealizedProfit
get

Get the total unrealised profit in our portfolio from the individual security unrealized profits.

Added alias for American spelling

Definition at line 411 of file SecurityPortfolioManager.cs.

◆ TotalPortfolioValue

decimal QuantConnect.Securities.SecurityPortfolioManager.TotalPortfolioValue
get

Total portfolio value if we sold all holdings at current market rates.

Cash + TotalUnrealisedProfit + TotalUnleveredAbsoluteHoldingsCost

See also
Cash, TotalUnrealizedProfit, TotalUnleveredAbsoluteHoldingsCost

Definition at line 423 of file SecurityPortfolioManager.cs.

◆ TotalPortfolioValueLessFreeBuffer

decimal QuantConnect.Securities.SecurityPortfolioManager.TotalPortfolioValueLessFreeBuffer
get

Returns the adjusted total portfolio value removing the free amount If the IAlgorithmSettings.FreePortfolioValue has not been set, the free amount will have a trailing behavior and be updated when requested

Definition at line 479 of file SecurityPortfolioManager.cs.

◆ TotalFees

decimal QuantConnect.Securities.SecurityPortfolioManager.TotalFees
get

Total fees paid during the algorithm operation across all securities in portfolio.

Definition at line 511 of file SecurityPortfolioManager.cs.

◆ TotalProfit

decimal QuantConnect.Securities.SecurityPortfolioManager.TotalProfit
get

Sum of all gross profit across all securities in portfolio and dividend payments.

Definition at line 522 of file SecurityPortfolioManager.cs.

◆ TotalNetProfit

decimal QuantConnect.Securities.SecurityPortfolioManager.TotalNetProfit
get

Sum of all net profit across all securities in portfolio and dividend payments.

Definition at line 533 of file SecurityPortfolioManager.cs.

◆ TotalSaleVolume

decimal QuantConnect.Securities.SecurityPortfolioManager.TotalSaleVolume
get

Total sale volume since the start of algorithm operations.

Definition at line 544 of file SecurityPortfolioManager.cs.

◆ TotalMarginUsed

decimal QuantConnect.Securities.SecurityPortfolioManager.TotalMarginUsed
get

Gets the total margin used across all securities in the account's currency

Definition at line 555 of file SecurityPortfolioManager.cs.

◆ MarginCallModel

IMarginCallModel QuantConnect.Securities.SecurityPortfolioManager.MarginCallModel
getset

Gets or sets the MarginCallModel for the portfolio. This is used to executed margin call orders.

Definition at line 591 of file SecurityPortfolioManager.cs.

◆ this[Symbol symbol]

override SecurityHolding QuantConnect.Securities.SecurityPortfolioManager.this[Symbol symbol]
getset

Indexer for the PortfolioManager class to access the underlying security holdings objects.

Parameters
symbolSymbol object indexer
Returns
SecurityHolding class from the algorithm securities

Definition at line 599 of file SecurityPortfolioManager.cs.


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