auradefi 0.1.1
PyPI GitHub

pnl_at

auradefi.accounting.pnl · source

PnL at an ARBITRARY date. The thing Zerion cannot do (SPEC §9).

Replays only the events at or before at_ms, in ONE pass, and reports as of that cutoff. Exactly equivalent to filtering the stream by time, calling process and then report, no marks are pre-computed at fixed dates, and no cutoff is privileged over any other, so a date 3,000 transactions from the nearest month end costs what any other date costs.

The filter is a generator, so events after the cutoff are skipped without being materialised. marks prices the units still held at the cutoff and follows the same rules as in report.

Parameters

eventsrequired, Iterable[AccountingEvent]

Acquisitions and disposals, in any order.

methodrequired, str

Costing method.
Possible values: "fifo", "lifo", "hifo", "acb"

at_msrequired, int

The instant to answer for. Any instant is answerable; nothing is pre-computed.

marksrequired, Mapping[str, Money]

Prices to value open lots at. Absent means unrealised is not computed for that asset.

Returns

PnLReport