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 377 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 386 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 395 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 404 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 413 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 421 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 429 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 444 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 455 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 467 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 477 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.

◆ 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 251 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 258 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 133 of file SecurityHolding.cs.

◆ Type

SecurityType QuantConnect.Securities.SecurityHolding.Type
get

The security type of the symbol

Definition at line 144 of file SecurityHolding.cs.

◆ Leverage

virtual decimal QuantConnect.Securities.SecurityHolding.Leverage
get

Leverage of the underlying security.

Definition at line 155 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 166 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 181 of file SecurityHolding.cs.

◆ Price

virtual decimal QuantConnect.Securities.SecurityHolding.Price
getprotected set

Current market price of the security.

Definition at line 189 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 205 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 216 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 227 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 244 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 264 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 272 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 280 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 289 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 301 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 313 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 324 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 336 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 346 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 357 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 369 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: