27 lines
3.5 KiB
Markdown
27 lines
3.5 KiB
Markdown
# ADR-002 — Money, cost basis, ownership and funding
|
|
|
|
Status: **approved by owner, 2026-10-22** (explicit “yes” to ADR-002/003/004 as written). This revision replaces the unimplemented half-even/rounded-average proposal; approval does not itself alter legacy code or accounts.
|
|
|
|
## Selected minimal policy
|
|
|
|
- Use a maintained checked decimal implementation (for example a pinned Rust decimal crate), not hand-written fixed-point arithmetic. Monetary postings and quantities use8 fractional digits initially. Explicit half-up/away-from-zero tie rounding matches the current TS `amount()` policy; tick/lot rules may be stricter. Reject unsupported precision, non-finite values and overflow.
|
|
- Decimal strings are financial command/snapshot transport. Market observations and statistical feature arrays need not become strings or be copied through the boundary per observation.
|
|
- **Remaining cost amount is authoritative. Average price is derived.** For a partial disposal release the proportional basis rounded at posting precision; the final disposal releases the exact remaining residual. Example: cost5 for3 shares must release exactly5 over all sales, not5.00000001 reconstructed from average1.66666667.
|
|
- Store owner-keyed quantity/cost/P&L from the first ledger implementation (F02 absorbs F03). Account quantities/basis aggregate those books. Fees are explicit separate postings; initial unallocated capital belongs to a reserve owner. Broker suspense handling is deferred with broker integration, not a generalized suspense-account subsystem now.
|
|
- First project-gated model is single-base-currency cash-funded long-only, no borrowing. Fee-inclusive reservations and fill-time checks live in Rust. Adverse gaps reject unaffordable remaining quantity rather than borrow or silently resize.
|
|
- No internal crossing/netting. Stable owner/intent admission priority; one owner cannot sell/cancel another's inventory. A strategy instance selects target OR explicit-order mode; mixing modes rejects in v1.
|
|
- Account daily-loss reset follows one declared account risk-session calendar, not each asset's venue or UTC date. Explicit boundary commands roll only the daily baseline. Drawdown peak/halt survives sessions and restore; authorized operator reset records its baseline.
|
|
|
|
## Legacy correction is different
|
|
|
|
C03 only adds unpaid-fee liability to the **existing non-reducing gross-capital test**. It preserves existing short/reducing behavior and8-place rounding. It is not the new cash-only account model and makes no claim to eliminate all debt in legacy short covers.
|
|
|
|
## Evidence / alternative costs
|
|
|
|
Historical TS amount/cost basis and aggregate owner attribution (`orchestrator/src/execution/model.ts`, retired in pre-M0 cleanup), [native fill broadcast](../../../../apps/stock/engine/src/backtest/engine.rs#L489). Exact postings fix arithmetic, not market modeling. A full multicurrency double-entry/margin/borrow engine is not required for v1.
|
|
|
|
## Migration and tests
|
|
|
|
F01 owns scalar/command fixtures; F02 implements owned books once; F04 owns funding/risk. Preserve old results; account conversion must reconcile quantities, cost residuals, cash and fees or refuse an implicit migration. No switch restoring a correctness defect. Required tests: positive/negative rounding ties, partial/final residual, A/B owner basis, duplicate fees, overflow and persisted daily/drawdown state.
|
|
|
|
“Project-gated” means the specified regression tests passed on declared modeling policies. It is not independent certification, proof of alpha, a broker guarantee or a generic certification framework.
|