caelum0x 798d5821a2 feat(quant): single-currency multi-instrument Portfolio aggregation
Add a `Portfolio` contract to lawsynth-quant: an ordered, single-currency
book of `Lot`s that aggregates exact cost basis, mark-to-market value,
gross notional, and unrealized P&L. Every total reuses `Money`'s
overflow-checked integer algebra, so figures are exact — no rounding, no
binary floating point, no silent wrapping.

Marks are supplied by a caller per-instrument resolver, so the portfolio
never sources or infers a price; an unpriced instrument is rejected rather
than defaulted to zero. Foreign-currency lots and mark currency mismatches
are rejected, never silently converted. Adds a deterministic versioned byte
encoding (`LSQF1`) with a length-prefixed lot sequence and a strict decoder
that rejects unknown versions, truncation, over-large lot counts,
currency drift, and trailing bytes.

Promotes the "multi-instrument portfolio aggregation" item that the Lot
slice deferred; realized P&L, lot-matched fill accounting, FX, financing,
and fees remain out of scope. Updates the quant-foundation spec + changelog
and adds a new `MissingMark` error variant. 5 new tests (18 total pass);
clippy -D warnings and rustfmt clean.
2026-08-26 14:58:18 +03:00

27 lines
1.4 KiB
Markdown

# Quant foundation changelog
## Unreleased
- Extend the exact money contract with overflow-checked negation, absolute
value, and integer scaling, plus a zero check; no rounding or FX is introduced.
- Add a single-position contract (direction, market value, notional, cash flow,
netting, reverse) that reuses the exact money integer algebra and its own
deterministic versioned byte encoding; no FX or multi-position aggregation.
- Add a single-lot mark-to-market P&L contract (cost basis, market value, exact
`quantity * (mark - entry)` unrealized profit) that reuses the exact money
integer algebra and a deterministic versioned byte encoding; currency
mismatches and overflow are rejected, and no realized P&L, FX, fees, or
multi-lot accumulation is introduced.
- Add a single-currency multi-instrument `Portfolio` that aggregates lots into
exact cost basis, mark-to-market value, gross notional, and unrealized P&L via
a caller-supplied per-instrument mark resolver, with a deterministic versioned
byte encoding and strict decoder. Foreign-currency lots, unpriced instruments,
mark currency mismatches, and overflow are rejected; no realized P&L,
lot-matched fill accounting, FX, financing, or fees are introduced.
## 0.1.0
- Define the initial closed currency set and exact minor-unit money contract.
- Define UTC millisecond observation identity with explicit same-time sequence.
- Define deterministic versioned byte encodings and strict decoders.