Skip to content

valuation_strategies

Valuation strategy implementations for the strategy-based ValuationService.

Classes:

Functions:

CarryingValueStrategy

Values positions at carrying value (amortized cost).

  • Amortizing loansacquisition_cost minus cumulative scheduled principal payments between acquisition_date and the current date. Matches the Loans and Advances ledger (debited at acquisition, credited on each AMORTIZATION transaction).
  • Bonds / other — clean acquisition cost (see :func:clean_acquisition_cost).

Methods:

  • value_batch

    Record carrying value for each position.

value_batch

value_batch(
    positions: list[Position],
    instruments: InstrumentStore,
    context: ValuationContext,
    output: ValuationStore,
) -> None

Record carrying value for each position.

FairValueStrategy

FairValueStrategy()

Values positions at fair value (NPV from QuantLib, or face_value fallback).

Methods:

  • value_batch

    Compute fair value for each position and record it.

value_batch

value_batch(
    positions: list[Position],
    instruments: InstrumentStore,
    context: ValuationContext,
    output: ValuationStore,
) -> None

Compute fair value for each position and record it.

ValuationStrategy

Bases: Protocol

Protocol that all valuation strategies must satisfy.

Methods:

  • value_batch

    Value positions in bulk and record results into output.

value_batch

value_batch(
    positions: list[Position],
    instruments: InstrumentStore,
    context: ValuationContext,
    output: ValuationStore,
) -> None

Value positions in bulk and record results into output.

clean_acquisition_cost

clean_acquisition_cost(
    position: Position, instrument: Instrument
) -> Decimal

Return the clean acquisition cost — the carrying value at initial recognition.

When a coupon-bearing bond is purchased between coupon dates the buyer pays a dirty price that includes accrued interest since the last coupon. At initial recognition the accounting entry splits the dirty price::

Dr  Investment account              (clean price)
Dr  Accrued Interest Receivable     (accrued interest)
Cr  Cash                            (dirty price = acquisition_cost)

The carrying value of the investment equals the clean price — the amount actually debited to the Investment account. This function computes acquisition_cost - accruedAmount(acquisition_date - 1) * face / 100.

We use acquisition_date - 1 day for consistency with the acquisition journal entry posted by :class:SimulationBuilder (see _compute_accrued_interest_at_acquisition for the detailed rationale).

For instruments without QuantLib accrued-amount support (loans, deposits, equity) the full acquisition_cost is returned unchanged.

default_valuation_strategies

default_valuation_strategies() -> dict

Return the default MeasurementBasis → ValuationStrategy mapping.