Lean  $LEAN_TAG$
QuantConnect.Securities.Cash Class Reference

Represents a holding of a currency in cash. More...

Public Member Functions

 Cash (string symbol, decimal amount, decimal conversionRate)
 Initializes a new instance of the Cash class More...
 
void Update ()
 Marks this cash object's conversion rate as being potentially outdated More...
 
decimal AddAmount (decimal amount)
 Adds the specified amount of currency to this Cash instance and returns the new total. This operation is thread-safe More...
 
void SetAmount (decimal amount)
 Sets the Quantity to the specified amount More...
 
List< SubscriptionDataConfigEnsureCurrencyDataFeed (SecurityManager securities, SubscriptionManager subscriptions, IReadOnlyDictionary< SecurityType, string > marketMap, SecurityChanges changes, ISecurityService securityService, string accountCurrency, Resolution defaultResolution=Resolution.Minute)
 Ensures that we have a data feed to convert this currency into the base currency. This will add a SubscriptionDataConfig and create a Security at the lowest resolution if one is not found. More...
 
override string ToString ()
 Returns a string that represents the current Cash. More...
 
string ToString (string accountCurrency)
 Returns a string that represents the current Cash. More...
 

Public Attributes

IEnumerable< SymbolSecuritySymbols
 Gets the symbols of the securities required to provide conversion rates. If this cash represents the account currency, then an empty enumerable is returned. More...
 
decimal ValueInAccountCurrency => Amount * ConversionRate
 Gets the value of this cash in the account currency More...
 

Properties

ICurrencyConversionCurrencyConversion [get, set]
 Gets the object that calculates the conversion rate to account currency More...
 
string Symbol [get]
 Gets the symbol used to represent this cash More...
 
decimal Amount [get]
 Gets or sets the amount of cash held More...
 
decimal ConversionRate [get, set]
 Gets the conversion rate into account currency More...
 
string CurrencySymbol [get]
 The symbol of the currency, such as $ More...
 

Events

EventHandler Updated
 Event fired when this instance is updated AddAmount, SetAmount, Update More...
 
EventHandler CurrencyConversionUpdated
 Event fired when this instance's CurrencyConversion is set/updated More...
 

Detailed Description

Represents a holding of a currency in cash.

Definition at line 33 of file Cash.cs.

Constructor & Destructor Documentation

◆ Cash()

QuantConnect.Securities.Cash.Cash ( string  symbol,
decimal  amount,
decimal  conversionRate 
)

Initializes a new instance of the Cash class

Parameters
symbolThe symbol used to represent this cash
amountThe amount of this currency held
conversionRateThe initial conversion rate of this currency into the CashBook.AccountCurrency

Definition at line 149 of file Cash.cs.

Here is the call graph for this function:

Member Function Documentation

◆ Update()

void QuantConnect.Securities.Cash.Update ( )

Marks this cash object's conversion rate as being potentially outdated

Definition at line 164 of file Cash.cs.

Here is the call graph for this function:

◆ AddAmount()

decimal QuantConnect.Securities.Cash.AddAmount ( decimal  amount)

Adds the specified amount of currency to this Cash instance and returns the new total. This operation is thread-safe

Parameters
amountThe amount of currency to be added
Returns
The amount of currency directly after the addition

Definition at line 175 of file Cash.cs.

Here is the caller graph for this function:

◆ SetAmount()

void QuantConnect.Securities.Cash.SetAmount ( decimal  amount)

Sets the Quantity to the specified amount

Parameters
amountThe amount to set the quantity to

Definition at line 189 of file Cash.cs.

Here is the caller graph for this function:

◆ EnsureCurrencyDataFeed()

List<SubscriptionDataConfig> QuantConnect.Securities.Cash.EnsureCurrencyDataFeed ( SecurityManager  securities,
SubscriptionManager  subscriptions,
IReadOnlyDictionary< SecurityType, string >  marketMap,
SecurityChanges  changes,
ISecurityService  securityService,
string  accountCurrency,
Resolution  defaultResolution = Resolution.Minute 
)

Ensures that we have a data feed to convert this currency into the base currency. This will add a SubscriptionDataConfig and create a Security at the lowest resolution if one is not found.

Parameters
securitiesThe security manager
subscriptionsThe subscription manager used for searching and adding subscriptions
marketMapThe market map that decides which market the new security should be in
changesWill be used to consume SecurityChanges.AddedSecurities
securityServiceWill be used to create required new Security
accountCurrencyThe account currency
defaultResolutionThe default resolution to use for the internal subscriptions
Returns
Returns the added SubscriptionDataConfig, otherwise null

Definition at line 221 of file Cash.cs.

Here is the call graph for this function:

◆ ToString() [1/2]

override string QuantConnect.Securities.Cash.ToString ( )

Returns a string that represents the current Cash.

Returns
A string that represents the current Cash.

Definition at line 342 of file Cash.cs.

◆ ToString() [2/2]

string QuantConnect.Securities.Cash.ToString ( string  accountCurrency)

Returns a string that represents the current Cash.

Returns
A string that represents the current Cash.

Definition at line 351 of file Cash.cs.

Member Data Documentation

◆ SecuritySymbols

IEnumerable<Symbol> QuantConnect.Securities.Cash.SecuritySymbols
Initial value:
=> CurrencyConversion.ConversionRateSecurities.Any()
? CurrencyConversion.ConversionRateSecurities.Select(x => x.Symbol)
: new List<Symbol>(0)

Gets the symbols of the securities required to provide conversion rates. If this cash represents the account currency, then an empty enumerable is returned.

Definition at line 54 of file Cash.cs.

◆ ValueInAccountCurrency

decimal QuantConnect.Securities.Cash.ValueInAccountCurrency => Amount * ConversionRate

Gets the value of this cash in the account currency

Definition at line 141 of file Cash.cs.

Property Documentation

◆ CurrencyConversion

ICurrencyConversion? QuantConnect.Securities.Cash.CurrencyConversion
getset

Gets the object that calculates the conversion rate to account currency

Definition at line 64 of file Cash.cs.

◆ Symbol

string QuantConnect.Securities.Cash.Symbol
get

Gets the symbol used to represent this cash

Definition at line 103 of file Cash.cs.

◆ Amount

decimal QuantConnect.Securities.Cash.Amount
get

Gets or sets the amount of cash held

Definition at line 109 of file Cash.cs.

◆ ConversionRate

decimal QuantConnect.Securities.Cash.ConversionRate
getset

Gets the conversion rate into account currency

Definition at line 116 of file Cash.cs.

◆ CurrencySymbol

string QuantConnect.Securities.Cash.CurrencySymbol
get

The symbol of the currency, such as $

Definition at line 136 of file Cash.cs.

Event Documentation

◆ Updated

EventHandler QuantConnect.Securities.Cash.Updated

Event fired when this instance is updated AddAmount, SetAmount, Update

Definition at line 43 of file Cash.cs.

◆ CurrencyConversionUpdated

EventHandler QuantConnect.Securities.Cash.CurrencyConversionUpdated

Event fired when this instance's CurrencyConversion is set/updated

Definition at line 48 of file Cash.cs.


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