Skip to content

Cash

QuantConnect.Securities.Cash

Cash(symbol: str, amount: float, conversion_rate: float)

Bases: Object

Represents a holding of a currency in cash.

Initializes a new instance of the Cash class

Parameters:

Name Type Description Default
symbol str

The symbol used to represent this cash

required
amount float

The amount of this currency held

required
conversion_rate float

The initial conversion rate of this currency into the CashBook.account_currency

required

updated

updated: _EventContainer[
    Callable[[Object, EventArgs], Any], Any
]

Event fired when this instance is updated add_amount, set_amount, update

currency_conversion_updated

currency_conversion_updated: _EventContainer[
    Callable[[Object, EventArgs], Any], Any
]

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

security_symbols

security_symbols: Iterable[Symbol]

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

currency_conversion

currency_conversion: ICurrencyConversion

Gets the object that calculates the conversion rate to account currency

symbol

symbol: str

Gets the symbol used to represent this cash

amount

amount: float

Gets or sets the amount of cash held

conversion_rate

conversion_rate: float

Gets the conversion rate into account currency

currency_symbol

currency_symbol: str

The symbol of the currency, such as $

value_in_account_currency

value_in_account_currency: float

Gets the value of this cash in the account currency

to_string

to_string() -> str
to_string(account_currency: str) -> str

Returns a string that represents the current Cash.

Returns:

Type Description
str

A string that represents the current Cash.

add_amount

add_amount(amount: float) -> float

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

Parameters:

Name Type Description Default
amount float

The amount of currency to be added

required

Returns:

Type Description
float

The amount of currency directly after the addition.

ensure_currency_data_feed

ensure_currency_data_feed(
    securities: SecurityManager,
    subscriptions: SubscriptionManager,
    market_map: IReadOnlyDictionary[SecurityType, str],
    changes: SecurityChanges,
    security_service: ISecurityService,
    account_currency: str,
    default_resolution: Resolution = ...,
) -> List[SubscriptionDataConfig]

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:

Name Type Description Default
securities SecurityManager

The security manager

required
subscriptions SubscriptionManager

The subscription manager used for searching and adding subscriptions

required
market_map IReadOnlyDictionary[SecurityType, str]

The market map that decides which market the new security should be in

required
changes SecurityChanges

Will be used to consume SecurityChanges.added_securities

required
security_service ISecurityService

Will be used to create required new Security

required
account_currency str

The account currency

required
default_resolution Resolution

The default resolution to use for the internal subscriptions

...

Returns:

Type Description
List[SubscriptionDataConfig]

Returns the added SubscriptionDataConfig, otherwise null.

set_amount

set_amount(amount: float) -> None

Sets the Quantity to the specified amount

Parameters:

Name Type Description Default
amount float

The amount to set the quantity to

required

update

update() -> None

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