feat(research): add owner-aware ledger and intraday storage
Implement reviewed F02/D02: exact owner accounting, atomic funding checks, idempotent receipts and ledger checkpoints; connect existing EOD intraday storage through validated research admission without active financial-engine cutover.
This commit is contained in:
parent
b4af840d4e
commit
b65acccd91
15 changed files with 2704 additions and 104 deletions
|
|
@ -14,6 +14,16 @@ Trace the actual intraday collection/schema, add the smallest provider adapter o
|
|||
|
||||
Measurable benefit: Makes supported intraday requests usable and honest.
|
||||
|
||||
### Verified ingestion evidence and seventh-wave boundary
|
||||
|
||||
Before implementation, inspected `apps/stock/data-ingestion/src/handlers/eod/actions/intraday.ts`: `fetchIntraday` looks up the listing, uses `eodExchange || Exchange`, copies provider Unix-second `timestamp`, `datetime`, `gmtoffset` and OHLCV, then upserts `eodIntraday1M`, `eodIntraday5M` or `eodIntraday1H` keyed by timestamp + `eodSearchCode` (lines 486–585 at base `b4af840`). The research reader currently chooses QuestDB first, otherwise only daily `eodPrices`.
|
||||
|
||||
Retain the common `getHistoricalBars` admission path. Add the existing EOD intraday mapping, explicit provider selection/capabilities and typed unavailable/unsupported errors. Capabilities describe connected stores and supported intervals, not proven range coverage. Preserve default QuestDB priority and never switch provider on an empty range/error. Explicit provider requests never fall back to daily or synthetic data. Validate whole Unix seconds and listing identity; Unix timestamps are already UTC and must not be shifted by `gmtoffset`. QM's adjusted/unpinned interval records remain unsupported.
|
||||
|
||||
Tests invoke the actual EOD writer with replaced HTTP/Mongo transport, then the real storage reader and v1/v2 dataset normalizers with explicit retained calendar/action metadata. This proves adapter composition, not database-server conformance or F06 replay. No optional v2 loader, active-runtime cutover or storage migration is required here.
|
||||
|
||||
Provider check (2026-10-22): [EODHD's intraday documentation](https://eodhd.com/financial-apis/intraday-historical-data-api) identifies the timestamp as UTC bar start and prices as unadjusted for subsequent corporate actions. It also describes delayed finalization after market close and possible historical corrections. Retrieval therefore does **not** establish point-in-time publication availability. Interval-end availability remains an explicit simulation assumption, never provider evidence; frozen content hashes retain the actual retrieved revision. Provider choice is initially a storage API parameter, not a new web/run-configuration control.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No unrelated refactor, new service or broker activation.
|
||||
|
|
|
|||
|
|
@ -15,6 +15,16 @@ Scheduling source of truth: [manifest entry F02](../manifest.json). No task is a
|
|||
|
||||
Implement one owner-keyed ledger from its first version; absorb F03 rather than building aggregate cost basis and replacing it later. Adapt existing Rust position calculations. Store owned quantity and remaining cost amount; derive average price and account aggregates. For a partial disposal, round the proportional released basis at posting precision; final disposal releases the exact residual. Fees are separate postings. Use one internal apply(state,command) kernel for resident research and staged durable transactions.
|
||||
|
||||
### Seventh-wave implementation boundary
|
||||
|
||||
F01 is committed in `b4af840`. Keep this ledger additive: no replacement of active legacy position/accounting code, native binding, SQL transaction integration or paper migration. ADR-005 remains unapproved; F02 provides the in-memory transition/checkpoint seam, not its durable adapter.
|
||||
|
||||
- A ledger checkpoint is distinct from F01's economic projection. It retains genesis, books including closed-position realized P&L, cash/fees, marks, risk-session identity, revision and ordered accepted receipts/aliases. Restore verifies by replay and canonical state comparison. It is not an order/replay/strategy/RNG session snapshot.
|
||||
- Exact multiplication and proportional release use maintained arithmetic with a single final half-away posting boundary, not precision-losing decimal intermediates. Account valuation sums owner-level marked postings; missing marks reject valuation instead of inventing zero or cost-based prices.
|
||||
- Invalid commands fail atomically without changing balances, books, marks or receipts. Basic cash funding includes fees. Reservation and portfolio risk policies remain F04, including recording accepted risk-rejection outcomes.
|
||||
- Identical command retry returns its original receipt even after later transitions. Identical fill under a new command ID aliases that receipt, explicitly marked replayed: compare event time and the entire canonical fill body, excluding only command ID. Different fill content or reuse of a fee ID by another fill rejects. Never emit duplicate economic deltas.
|
||||
- Normal transitions stage only affected state; checkpoint serialization/replay is explicit. Record repeatable scoped transition and checkpoint/restore measurements without claiming end-to-end research throughput.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No unrelated refactor, new service, broker enablement, or silent reinterpretation of historical results.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue