Ledger

class app.portfolio.models.ledger.ledger.Ledger[source]

Bases: Sequence, NamedInstanceStoreEntityMixin, AutomaticNamedEntity

Inheritance diagram of Ledger

Inheritance Diagram for Ledger

Methods

by_instrument(instrument)

Returns the ledger instance associated with the given instrument.

calculate_instance_name_from_dict(data)

Convert the provided keyword arguments to an instance name.

Attributes

instance_name

length

Returns the number of transactions in the ledger.

model_config

Configuration for the model, should be a dictionary conforming to ConfigDict.

instrument

transactions

uid

entity_log

version

instance_parent

classmethod by_instrument(instrument)[source]

Returns the ledger instance associated with the given instrument. If no ledger exists for the instrument, returns None.

Return type:

Ledger | None

Parameters:

instrument (Instrument)

classmethod calculate_instance_name_from_dict(data)[source]

Convert the provided keyword arguments to an instance name. This method should be implemented by subclasses to define how to derive the instance name.

Return type:

str

Parameters:

data (dict[str, Any])

property instance_name: str
instrument: Instrument
property length: int

Returns the number of transactions in the ledger. This is a computed property that provides the length of the transactions list.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}

Configuration for the model, should be a dictionary conforming to ConfigDict.

transactions: tuple[Transaction, ...]