Skip to content
Hugh Jeremy edited this page Mar 27, 2019 · 5 revisions

Documentation > Ledger

A Ledger is a list of Transactions from the perspective of a particular Account. Ledgers are ordered by Transaction time, and include a running Account Balance for every line.

You can request Ledgers in arbitrary Global or Custom Units, not just the native unit of the target Account. If you request a Ledger in a unit other than the target Account native unit, Amatino will compute and return unrealised gains and losses.

Amatino will return a maximum total of 1,000 Ledger Rows per retrieval request. If the Ledger you define spans more than 1,000 rows, it will be broken into pages you can retrieve separately.

Ledger complies with the Python Sequence protocol, meaning you can iterate over constituent LedgerRows, call len(), and access elements by subscript.

Properties

.session - Session

The Session used to initialise this Ledger


.entity - Entity

The Entity of which this the data described in this Ledger are members


.account_id - int

The integer identifier of the Account this Ledger describes

Example: 420


.account - Account

The Account that this Ledger describes.


.denomination - Denomation

The denominating unit of this Ledger, either a GlobalUnit or a CustomUnit


.start_time - datetime

The earliest Transaction time presented by this Ledger.


.end_time - datetime

The latest Transactiontime presented by thisLedger.


.recursive - bool

An assertion that this is not a RecursiveLedger

Example: False


.generated_time - datetime

The time at which this Ledger object was generated.


.global_unit_id - Optional[int]

The integer identifier of the GlobalUnit denominating this Ledger, if any.

Example: 5


.custom_unit_id - Optional[int]

The integer identifier of the CustomUnit denominating this Ledger, if any.

Example: None


.page - int

The integer number of the page of all potential Ledger data that this Ledger instance presents.

Example: 1


.number_of_pages - int

The integer number of pages that in total cover all potential Ledger data meeting the parameters supplied


.order - LedgerOrder

The order in which [LedgerRows] are presented in this Ledger instance, either youngest first or oldest first.

Example: LedgerOrder.YOUNGEST_FIRST


.rows - List[LedgerRow]

A list of LedgerRow instances describing all the Transactions satisfying the parameters supplied to this Ledger

Methods

classmethod .retrieve() -> Ledger

Return a new Ledger instance.

Parameters

  1. entity - Entity
  2. account - Account
  3. order - LedgerOrder (Defaults to .YOUNGEST_FIRST)
  4. page - int (Defaults to 1)
  5. start_time - Optional[datetime]
  6. end_time - Optional[datetime]
  7. denomination - Optional[Denomination]

Example

ledger = Ledger.retrieve(
  entity=mega_corp,
  account=cash_account
)
for row in ledger:
  print(row.balance)

Clone this wiki locally