Lean  $LEAN_TAG$
QuantConnect.Securities.CashBook Class Reference

Provides a means of keeping track of the different cash holdings of an algorithm More...

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

Public Member Functions

 CashBook ()
 Initializes a new instance of the CashBook class. More...
 
Cash Add (string symbol, decimal quantity, decimal conversionRate)
 Adds a new cash of the specified symbol and quantity More...
 
List< SubscriptionDataConfigEnsureCurrencyDataFeeds (SecurityManager securities, SubscriptionManager subscriptions, IReadOnlyDictionary< SecurityType, string > marketMap, SecurityChanges changes, ISecurityService securityService, Resolution defaultResolution=Resolution.Minute)
 Checks the current subscriptions and adds necessary currency pair feeds to provide real time conversion data More...
 
decimal Convert (decimal sourceQuantity, string sourceCurrency, string destinationCurrency)
 Converts a quantity of source currency units into the specified destination currency More...
 
decimal ConvertToAccountCurrency (decimal sourceQuantity, string sourceCurrency)
 Converts a quantity of source currency units into the account currency More...
 
override string ToString ()
 Returns a string that represents the current object. More...
 
void Add (KeyValuePair< string, Cash > item)
 Add the specified item to this CashBook. More...
 
void Add (string symbol, Cash value)
 Add the specified key and value. More...
 
void Clear ()
 Clear this instance of all Cash entries. More...
 
bool Remove (string symbol)
 Remove the Cash item corresponding to the specified symbol More...
 
bool Remove (KeyValuePair< string, Cash > item)
 Remove the specified item. More...
 
bool ContainsKey (string symbol)
 Determines whether the current instance contains an entry with the specified symbol. More...
 
bool TryGetValue (string symbol, out Cash value)
 Try to get the value. More...
 
bool Contains (KeyValuePair< string, Cash > item)
 Determines whether the current collection contains the specified value. More...
 
void CopyTo (KeyValuePair< string, Cash >[] array, int arrayIndex)
 Copies to the specified array. More...
 
IEnumerator< KeyValuePair< string, Cash > > GetEnumerator ()
 Gets the enumerator. More...
 
CashAmount ConvertToAccountCurrency (CashAmount cashAmount)
 Converts a cash amount to the account currency More...
 

Public Attributes

ICollection< string > Keys => _currencies.Keys
 Gets the keys. More...
 
ICollection< CashValues => _currencies.Values
 Gets the values. More...
 

Properties

string AccountCurrency [get, set]
 Gets the base currency used More...
 
decimal TotalValueInAccountCurrency [get]
 Gets the total value of the cash book in units of the base currency More...
 
int Count [get]
 Gets the count of Cash items in this CashBook. More...
 
bool IsReadOnly [get]
 Gets a value indicating whether this instance is read only. More...
 
Cash this[string symbol] [get, set]
 Gets or sets the QuantConnect.Securities.Cash with the specified symbol. More...
 
- Properties inherited from QuantConnect.Securities.ICurrencyConverter
string AccountCurrency [get]
 Gets account currency More...
 

Events

EventHandler< CashBookUpdatedEventArgsUpdated
 Event fired when a Cash instance is added or removed, and when the Cash.Updated is triggered for the currently hold instances More...
 

Detailed Description

Provides a means of keeping track of the different cash holdings of an algorithm

Definition at line 32 of file CashBook.cs.

Constructor & Destructor Documentation

◆ CashBook()

QuantConnect.Securities.CashBook.CashBook ( )

Initializes a new instance of the CashBook class.

Definition at line 86 of file CashBook.cs.

Member Function Documentation

◆ Add() [1/3]

Cash QuantConnect.Securities.CashBook.Add ( string  symbol,
decimal  quantity,
decimal  conversionRate 
)

Adds a new cash of the specified symbol and quantity

Parameters
symbolThe symbol used to reference the new cash
quantityThe amount of new cash to start
conversionRateThe conversion rate used to determine the initial portfolio value/starting capital impact caused by this currency position.
Returns
The added cash instance

Definition at line 100 of file CashBook.cs.

Here is the caller graph for this function:

◆ EnsureCurrencyDataFeeds()

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

Checks the current subscriptions and adds necessary currency pair feeds to provide real time conversion data

Parameters
securitiesThe SecurityManager for the algorithm
subscriptionsThe SubscriptionManager for the algorithm
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
defaultResolutionThe default resolution to use for the internal subscriptions
Returns
Returns a list of added currency SubscriptionDataConfig

Definition at line 117 of file CashBook.cs.

◆ Convert()

decimal QuantConnect.Securities.CashBook.Convert ( decimal  sourceQuantity,
string  sourceCurrency,
string  destinationCurrency 
)

Converts a quantity of source currency units into the specified destination currency

Parameters
sourceQuantityThe quantity of source currency to be converted
sourceCurrencyThe source currency symbol
destinationCurrencyThe destination currency symbol
Returns
The converted value

Definition at line 155 of file CashBook.cs.

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

◆ ConvertToAccountCurrency() [1/2]

decimal QuantConnect.Securities.CashBook.ConvertToAccountCurrency ( decimal  sourceQuantity,
string  sourceCurrency 
)

Converts a quantity of source currency units into the account currency

Parameters
sourceQuantityThe quantity of source currency to be converted
sourceCurrencyThe source currency symbol
Returns
The converted value

Definition at line 185 of file CashBook.cs.

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

◆ ToString()

override string QuantConnect.Securities.CashBook.ToString ( )

Returns a string that represents the current object.

Returns
A string that represents the current object.

<filterpriority>2</filterpriority>

Definition at line 201 of file CashBook.cs.

Here is the call graph for this function:

◆ Add() [2/3]

void QuantConnect.Securities.CashBook.Add ( KeyValuePair< string, Cash item)

Add the specified item to this CashBook.

Parameters
itemKeyValuePair of symbol -> Cash item

Definition at line 233 of file CashBook.cs.

Here is the call graph for this function:

◆ Add() [3/3]

void QuantConnect.Securities.CashBook.Add ( string  symbol,
Cash  value 
)

Add the specified key and value.

Parameters
symbolThe symbol of the Cash value.
valueValue.

Definition at line 243 of file CashBook.cs.

◆ Clear()

void QuantConnect.Securities.CashBook.Clear ( )

Clear this instance of all Cash entries.

Definition at line 251 of file CashBook.cs.

◆ Remove() [1/2]

bool QuantConnect.Securities.CashBook.Remove ( string  symbol)

Remove the Cash item corresponding to the specified symbol

Parameters
symbolThe symbolto be removed

Definition at line 261 of file CashBook.cs.

Here is the caller graph for this function:

◆ Remove() [2/2]

bool QuantConnect.Securities.CashBook.Remove ( KeyValuePair< string, Cash item)

Remove the specified item.

Parameters
itemItem.

Definition at line 270 of file CashBook.cs.

Here is the call graph for this function:

◆ ContainsKey()

bool QuantConnect.Securities.CashBook.ContainsKey ( string  symbol)

Determines whether the current instance contains an entry with the specified symbol.

Returns
true, if key was contained, false otherwise.
Parameters
symbolKey.

Definition at line 280 of file CashBook.cs.

Here is the caller graph for this function:

◆ TryGetValue()

bool QuantConnect.Securities.CashBook.TryGetValue ( string  symbol,
out Cash  value 
)

Try to get the value.

To be added.

Returns
true, if get value was tryed, false otherwise.
Parameters
symbolThe symbol.
valueValue.

Definition at line 292 of file CashBook.cs.

Here is the caller graph for this function:

◆ Contains()

bool QuantConnect.Securities.CashBook.Contains ( KeyValuePair< string, Cash item)

Determines whether the current collection contains the specified value.

Parameters
itemItem.

Definition at line 301 of file CashBook.cs.

◆ CopyTo()

void QuantConnect.Securities.CashBook.CopyTo ( KeyValuePair< string, Cash >[]  array,
int  arrayIndex 
)

Copies to the specified array.

Parameters
arrayArray.
arrayIndexArray index.

Definition at line 311 of file CashBook.cs.

◆ GetEnumerator()

IEnumerator<KeyValuePair<string, Cash> > QuantConnect.Securities.CashBook.GetEnumerator ( )

Gets the enumerator.

Returns
The enumerator.

Definition at line 357 of file CashBook.cs.

◆ ConvertToAccountCurrency() [2/2]

CashAmount QuantConnect.Securities.CashBook.ConvertToAccountCurrency ( CashAmount  cashAmount)

Converts a cash amount to the account currency

Parameters
cashAmountThe CashAmount instance to convert
Returns
A new CashAmount instance denominated in the account currency

Implements QuantConnect.Securities.ICurrencyConverter.

Definition at line 376 of file CashBook.cs.

Here is the call graph for this function:

Member Data Documentation

◆ Keys

ICollection<string> QuantConnect.Securities.CashBook.Keys => _currencies.Keys

Gets the keys.

The keys.

Definition at line 345 of file CashBook.cs.

◆ Values

ICollection<Cash> QuantConnect.Securities.CashBook.Values => _currencies.Values

Gets the values.

The values.

Definition at line 351 of file CashBook.cs.

Property Documentation

◆ AccountCurrency

string QuantConnect.Securities.CashBook.AccountCurrency
getset

Gets the base currency used

Definition at line 46 of file CashBook.cs.

◆ TotalValueInAccountCurrency

decimal QuantConnect.Securities.CashBook.TotalValueInAccountCurrency
get

Gets the total value of the cash book in units of the base currency

Definition at line 76 of file CashBook.cs.

◆ Count

int QuantConnect.Securities.CashBook.Count
get

Gets the count of Cash items in this CashBook.

The count.

Definition at line 213 of file CashBook.cs.

◆ IsReadOnly

bool QuantConnect.Securities.CashBook.IsReadOnly
get

Gets a value indicating whether this instance is read only.

true if this instance is read only; otherwise, false.

Definition at line 225 of file CashBook.cs.

◆ this[string symbol]

Cash QuantConnect.Securities.CashBook.this[string symbol]
getset

Gets or sets the QuantConnect.Securities.Cash with the specified symbol.

Parameters
symbolSymbol.

Definition at line 321 of file CashBook.cs.

Event Documentation

◆ Updated

EventHandler<CashBookUpdatedEventArgs> QuantConnect.Securities.CashBook.Updated

Event fired when a Cash instance is added or removed, and when the Cash.Updated is triggered for the currently hold instances

Definition at line 40 of file CashBook.cs.


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