Lean  $LEAN_TAG$
QuantConnect.Securities.SecurityHolding Class Reference

SecurityHolding is a base class for purchasing and holding a market item which manages the asset portfolio More...

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

Public Member Functions

 SecurityHolding (Security security, ICurrencyConverter currencyConverter)
 Create a new holding class instance setting the initial properties to $0. More...
 
void AddNewFee (decimal newFee)
 Adds a fee to the running total of total fees in units of the account's currency. More...
 
void AddNewProfit (decimal profitLoss)
 Adds a profit record to the running total of profit in units of the account's currency. More...
 
void AddNewSale (decimal saleValue)
 Adds a new sale value to the running total trading volume in units of the account's currency. More...
 
void AddNewDividend (decimal dividend)
 Adds a new dividend payment to the running total dividend in units of the account's currency. More...
 
void SetLastTradeProfit (decimal lastTradeProfit)
 Set the last trade profit for this security from a Portfolio.ProcessFill call in units of the account's currency. More...
 
virtual void SetHoldings (decimal averagePrice, int quantity)
 Set the quantity of holdings and their average price after processing a portfolio fill. More...
 
virtual void SetHoldings (decimal averagePrice, decimal quantity)
 Set the quantity of holdings and their average price after processing a portfolio fill. More...
 
virtual void UpdateMarketPrice (decimal closingPrice)
 Update local copy of closing price value. More...
 
virtual ConvertibleCashAmount GetQuantityValue (decimal quantity)
 Gets the total value of the specified quantity of shares of this security in the account currency More...
 
virtual ConvertibleCashAmount GetQuantityValue (decimal quantity, decimal price)
 Gets the total value of the specified quantity of shares of this security in the account currency More...
 
virtual decimal TotalCloseProfit (bool includeFees=true, decimal? exitPrice=null, decimal? entryPrice=null, decimal? quantity=null)
 Profit if we closed the holdings right now including the approximate fees in units of the account's currency. More...
 
override string ToString ()
 Writes out the properties of this instance to string More...
 

Public Attributes

virtual bool HoldStock => _invested
 Boolean flag indicating if we hold any of the security More...
 
virtual bool Invested => _invested
 Boolean flag indicating if we hold any of the security More...
 

Protected Member Functions

 SecurityHolding (SecurityHolding holding)
 Create a new holding class instance copying the initial properties More...
 
virtual void OnQuantityChanged (decimal previousAveragePrice, decimal previousQuantity)
 Event invocator for the QuantityChanged event More...
 

Properties

Security Security [get]
 The security being held More...
 
IPortfolioTarget Target [get, set]
 Gets the current target holdings for this security More...
 
decimal AveragePrice [get, protected set]
 Average price of the security holdings. More...
 
decimal Quantity [get, protected set]
 Quantity of the security held. More...
 
Symbol Symbol [get]
 Symbol identifier of the underlying security. More...
 
SecurityType Type [get]
 The security type of the symbol More...
 
virtual decimal Leverage [get]
 Leverage of the underlying security. More...
 
virtual decimal HoldingsCost [get]
 Acquisition cost of the security total holdings in units of the account's currency. More...
 
virtual decimal UnleveredHoldingsCost [get]
 Unlevered Acquisition cost of the security total holdings in units of the account's currency. More...
 
virtual decimal Price [get, protected set]
 Current market price of the security. More...
 
virtual decimal AbsoluteHoldingsCost [get]
 Absolute holdings cost for current holdings in units of the account's currency. More...
 
virtual decimal UnleveredAbsoluteHoldingsCost [get]
 Unlevered absolute acquisition cost of the security total holdings in units of the account's currency. More...
 
virtual decimal HoldingsValue [get]
 Market value of our holdings in units of the account's currency. More...
 
virtual decimal AbsoluteHoldingsValue [get]
 Absolute of the market value of our holdings in units of the account's currency. More...
 
virtual decimal TotalSaleVolume [get]
 The total transaction volume for this security since the algorithm started in units of the account's currency. More...
 
virtual decimal TotalFees [get]
 Total fees for this company since the algorithm started in units of the account's currency. More...
 
virtual decimal TotalDividends [get]
 Total dividends for this company since the algorithm started in units of the account's currency. More...
 
virtual bool IsLong [get]
 Boolean flag indicating we have a net positive holding of the security. More...
 
virtual bool IsShort [get]
 BBoolean flag indicating we have a net negative holding of the security. More...
 
virtual decimal AbsoluteQuantity [get]
 Absolute quantity of holdings of this security More...
 
virtual decimal LastTradeProfit [get]
 Record of the closing profit from the last trade conducted in units of the account's currency. More...
 
virtual decimal Profit [get]
 Calculate the total profit for this security in units of the account's currency. More...
 
virtual decimal NetProfit [get]
 Return the net for this company measured by the profit less fees in units of the account's currency. More...
 
virtual decimal UnrealizedProfitPercent [get]
 Gets the unrealized profit as a percentage of holdings cost More...
 
virtual decimal UnrealizedProfit [get]
 Unrealized profit of this security when absolute quantity held is more than zero in units of the account's currency. More...
 

Events

EventHandler< SecurityHoldingQuantityChangedEventArgsQuantityChanged
 Event raised each time the holdings quantity is changed. More...
 

Detailed Description

SecurityHolding is a base class for purchasing and holding a market item which manages the asset portfolio

Definition at line 26 of file SecurityHolding.cs.

Constructor & Destructor Documentation

◆ SecurityHolding() [1/2]

QuantConnect.Securities.SecurityHolding.SecurityHolding ( Security  security,
ICurrencyConverter  currencyConverter 
)

Create a new holding class instance setting the initial properties to $0.

Parameters
securityThe security being held
currencyConverterA currency converter instance

Definition at line 51 of file SecurityHolding.cs.

◆ SecurityHolding() [2/2]

QuantConnect.Securities.SecurityHolding.SecurityHolding ( SecurityHolding  holding)
protected

Create a new holding class instance copying the initial properties

Parameters
holdingThe security being held

Definition at line 64 of file SecurityHolding.cs.

Member Function Documentation

◆ AddNewFee()

void QuantConnect.Securities.SecurityHolding.AddNewFee ( decimal  newFee)

Adds a fee to the running total of total fees in units of the account's currency.

Parameters
newFee

Definition at line 379 of file SecurityHolding.cs.

Here is the caller graph for this function:

◆ AddNewProfit()

void QuantConnect.Securities.SecurityHolding.AddNewProfit ( decimal  profitLoss)

Adds a profit record to the running total of profit in units of the account's currency.

Parameters
profitLossThe cash change in portfolio from closing a position

Definition at line 388 of file SecurityHolding.cs.

Here is the caller graph for this function:

◆ AddNewSale()

void QuantConnect.Securities.SecurityHolding.AddNewSale ( decimal  saleValue)

Adds a new sale value to the running total trading volume in units of the account's currency.

Parameters
saleValue

Definition at line 397 of file SecurityHolding.cs.

Here is the caller graph for this function:

◆ AddNewDividend()

void QuantConnect.Securities.SecurityHolding.AddNewDividend ( decimal  dividend)

Adds a new dividend payment to the running total dividend in units of the account's currency.

Parameters
dividend

Definition at line 406 of file SecurityHolding.cs.

◆ SetLastTradeProfit()

void QuantConnect.Securities.SecurityHolding.SetLastTradeProfit ( decimal  lastTradeProfit)

Set the last trade profit for this security from a Portfolio.ProcessFill call in units of the account's currency.

Parameters
lastTradeProfitValue of the last trade profit

Definition at line 415 of file SecurityHolding.cs.

Here is the caller graph for this function:

◆ SetHoldings() [1/2]

virtual void QuantConnect.Securities.SecurityHolding.SetHoldings ( decimal  averagePrice,
int  quantity 
)
virtual

Set the quantity of holdings and their average price after processing a portfolio fill.

Definition at line 423 of file SecurityHolding.cs.

Here is the caller graph for this function:

◆ SetHoldings() [2/2]

virtual void QuantConnect.Securities.SecurityHolding.SetHoldings ( decimal  averagePrice,
decimal  quantity 
)
virtual

Set the quantity of holdings and their average price after processing a portfolio fill.

Definition at line 431 of file SecurityHolding.cs.

Here is the call graph for this function:

◆ UpdateMarketPrice()

virtual void QuantConnect.Securities.SecurityHolding.UpdateMarketPrice ( decimal  closingPrice)
virtual

Update local copy of closing price value.

Parameters
closingPricePrice of the underlying asset to be used for calculating market price / portfolio value

Definition at line 446 of file SecurityHolding.cs.

Here is the caller graph for this function:

◆ GetQuantityValue() [1/2]

virtual ConvertibleCashAmount QuantConnect.Securities.SecurityHolding.GetQuantityValue ( decimal  quantity)
virtual

Gets the total value of the specified quantity of shares of this security in the account currency

Parameters
quantityThe quantity of shares
Returns
The value of the quantity of shares in the account currency

Definition at line 457 of file SecurityHolding.cs.

Here is the caller graph for this function:

◆ GetQuantityValue() [2/2]

virtual ConvertibleCashAmount QuantConnect.Securities.SecurityHolding.GetQuantityValue ( decimal  quantity,
decimal  price 
)
virtual

Gets the total value of the specified quantity of shares of this security in the account currency

Parameters
quantityThe quantity of shares
priceThe current price
Returns
The value of the quantity of shares in the account currency

Reimplemented in QuantConnect.Securities.CryptoFuture.CryptoFutureHolding.

Definition at line 469 of file SecurityHolding.cs.

◆ TotalCloseProfit()

virtual decimal QuantConnect.Securities.SecurityHolding.TotalCloseProfit ( bool  includeFees = true,
decimal?  exitPrice = null,
decimal?  entryPrice = null,
decimal?  quantity = null 
)
virtual

Profit if we closed the holdings right now including the approximate fees in units of the account's currency.

Does not use the transaction model for market fills but should.

Definition at line 479 of file SecurityHolding.cs.

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

◆ ToString()

override string QuantConnect.Securities.SecurityHolding.ToString ( )

Writes out the properties of this instance to string

Definition at line 512 of file SecurityHolding.cs.

Here is the call graph for this function:

◆ OnQuantityChanged()

virtual void QuantConnect.Securities.SecurityHolding.OnQuantityChanged ( decimal  previousAveragePrice,
decimal  previousQuantity 
)
protectedvirtual

Event invocator for the QuantityChanged event

Definition at line 520 of file SecurityHolding.cs.

Here is the caller graph for this function:

Member Data Documentation

◆ HoldStock

virtual bool QuantConnect.Securities.SecurityHolding.HoldStock => _invested

Boolean flag indicating if we hold any of the security

Definition at line 253 of file SecurityHolding.cs.

◆ Invested

virtual bool QuantConnect.Securities.SecurityHolding.Invested => _invested

Boolean flag indicating if we hold any of the security

Alias of HoldStock

See also
HoldStock

Definition at line 260 of file SecurityHolding.cs.

Property Documentation

◆ Security

Security QuantConnect.Securities.SecurityHolding.Security
getprotected

The security being held

Definition at line 81 of file SecurityHolding.cs.

◆ Target

IPortfolioTarget QuantConnect.Securities.SecurityHolding.Target
getset

Gets the current target holdings for this security

Definition at line 92 of file SecurityHolding.cs.

◆ AveragePrice

decimal QuantConnect.Securities.SecurityHolding.AveragePrice
getprotected set

Average price of the security holdings.

Definition at line 100 of file SecurityHolding.cs.

◆ Quantity

decimal QuantConnect.Securities.SecurityHolding.Quantity
getprotected set

Quantity of the security held.

Positive indicates long holdings, negative quantity indicates a short holding

See also
AbsoluteQuantity

Definition at line 117 of file SecurityHolding.cs.

◆ Symbol

Symbol QuantConnect.Securities.SecurityHolding.Symbol
get

Symbol identifier of the underlying security.

Definition at line 135 of file SecurityHolding.cs.

◆ Type

SecurityType QuantConnect.Securities.SecurityHolding.Type
get

The security type of the symbol

Definition at line 146 of file SecurityHolding.cs.

◆ Leverage

virtual decimal QuantConnect.Securities.SecurityHolding.Leverage
get

Leverage of the underlying security.

Definition at line 157 of file SecurityHolding.cs.

◆ HoldingsCost

virtual decimal QuantConnect.Securities.SecurityHolding.HoldingsCost
get

Acquisition cost of the security total holdings in units of the account's currency.

Definition at line 168 of file SecurityHolding.cs.

◆ UnleveredHoldingsCost

virtual decimal QuantConnect.Securities.SecurityHolding.UnleveredHoldingsCost
get

Unlevered Acquisition cost of the security total holdings in units of the account's currency.

Definition at line 183 of file SecurityHolding.cs.

◆ Price

virtual decimal QuantConnect.Securities.SecurityHolding.Price
getprotected set

Current market price of the security.

Definition at line 191 of file SecurityHolding.cs.

◆ AbsoluteHoldingsCost

virtual decimal QuantConnect.Securities.SecurityHolding.AbsoluteHoldingsCost
get

Absolute holdings cost for current holdings in units of the account's currency.

See also
HoldingsCost

Definition at line 207 of file SecurityHolding.cs.

◆ UnleveredAbsoluteHoldingsCost

virtual decimal QuantConnect.Securities.SecurityHolding.UnleveredAbsoluteHoldingsCost
get

Unlevered absolute acquisition cost of the security total holdings in units of the account's currency.

Definition at line 218 of file SecurityHolding.cs.

◆ HoldingsValue

virtual decimal QuantConnect.Securities.SecurityHolding.HoldingsValue
get

Market value of our holdings in units of the account's currency.

Definition at line 229 of file SecurityHolding.cs.

◆ AbsoluteHoldingsValue

virtual decimal QuantConnect.Securities.SecurityHolding.AbsoluteHoldingsValue
get

Absolute of the market value of our holdings in units of the account's currency.

See also
HoldingsValue

Definition at line 246 of file SecurityHolding.cs.

◆ TotalSaleVolume

virtual decimal QuantConnect.Securities.SecurityHolding.TotalSaleVolume
get

The total transaction volume for this security since the algorithm started in units of the account's currency.

Definition at line 266 of file SecurityHolding.cs.

◆ TotalFees

virtual decimal QuantConnect.Securities.SecurityHolding.TotalFees
get

Total fees for this company since the algorithm started in units of the account's currency.

Definition at line 274 of file SecurityHolding.cs.

◆ TotalDividends

virtual decimal QuantConnect.Securities.SecurityHolding.TotalDividends
get

Total dividends for this company since the algorithm started in units of the account's currency.

Definition at line 282 of file SecurityHolding.cs.

◆ IsLong

virtual bool QuantConnect.Securities.SecurityHolding.IsLong
get

Boolean flag indicating we have a net positive holding of the security.

See also
IsShort

Definition at line 291 of file SecurityHolding.cs.

◆ IsShort

virtual bool QuantConnect.Securities.SecurityHolding.IsShort
get

BBoolean flag indicating we have a net negative holding of the security.

See also
IsLong

Definition at line 303 of file SecurityHolding.cs.

◆ AbsoluteQuantity

virtual decimal QuantConnect.Securities.SecurityHolding.AbsoluteQuantity
get

Absolute quantity of holdings of this security

See also
Quantity

Definition at line 315 of file SecurityHolding.cs.

◆ LastTradeProfit

virtual decimal QuantConnect.Securities.SecurityHolding.LastTradeProfit
get

Record of the closing profit from the last trade conducted in units of the account's currency.

Definition at line 326 of file SecurityHolding.cs.

◆ Profit

virtual decimal QuantConnect.Securities.SecurityHolding.Profit
get

Calculate the total profit for this security in units of the account's currency.

See also
NetProfit

Definition at line 338 of file SecurityHolding.cs.

◆ NetProfit

virtual decimal QuantConnect.Securities.SecurityHolding.NetProfit
get

Return the net for this company measured by the profit less fees in units of the account's currency.

See also
Profit, TotalFees

Definition at line 348 of file SecurityHolding.cs.

◆ UnrealizedProfitPercent

virtual decimal QuantConnect.Securities.SecurityHolding.UnrealizedProfitPercent
get

Gets the unrealized profit as a percentage of holdings cost

Definition at line 359 of file SecurityHolding.cs.

◆ UnrealizedProfit

virtual decimal QuantConnect.Securities.SecurityHolding.UnrealizedProfit
get

Unrealized profit of this security when absolute quantity held is more than zero in units of the account's currency.

Definition at line 371 of file SecurityHolding.cs.

Event Documentation

◆ QuantityChanged

EventHandler<SecurityHoldingQuantityChangedEventArgs> QuantConnect.Securities.SecurityHolding.QuantityChanged

Event raised each time the holdings quantity is changed.

Definition at line 31 of file SecurityHolding.cs.


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