From b6345400477d148e20fb4a6b2c44907e87607655 Mon Sep 17 00:00:00 2001 From: boris Date: Mon, 31 Aug 2026 02:44:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BA=E5=8C=96=E5=AE=9A=E7=82=B9=E9=87=91?= =?UTF-8?q?=E9=A2=9D=E4=B8=8E=E5=88=86=E9=92=9F=E6=B5=81=E5=BC=8F=E9=AA=8C?= =?UTF-8?q?=E6=94=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/engine-capability-roadmap.md | 12 ++- .../fixed-point-minute-acceptance-20260831.md | 75 +++++++++++++++++++ 2 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 docs/fixed-point-minute-acceptance-20260831.md diff --git a/docs/engine-capability-roadmap.md b/docs/engine-capability-roadmap.md index cba2ca3..f8f1825 100644 --- a/docs/engine-capability-roadmap.md +++ b/docs/engine-capability-roadmap.md @@ -10,7 +10,7 @@ The roadmap focuses on making the engine complete enough for editable platform strategies, long-range A-share backtests, futures strategies, intraday order simulation, AI-generated strategy code, and service-level result downloads. -## Re-Audit Findings (2026-04-24) +## Re-Audit Findings (2026-08-31) The latest re-audit focused on the engine's execution model, account model, order lifecycle, data helper surface, analyzer output, extension hooks, and @@ -39,7 +39,8 @@ futures path. Confirmed aligned areas: | P0 | Futures intraday matching | Closed for daily/open/close, tick-price futures fills, and true multi-level order-book sweeping when optional `order_book_depth` data exists. L1-only data still uses the existing L1 matcher and is not inflated into fake depth. | Extend depth fields only if production vendors expose more levels or exchange-specific fields. | | P0 | Futures open-order lifecycle | Closed for futures pending limit orders, cross-day rematching, cancellation by id/symbol/all, and merged open-order runtime views. | Add more order status transitions only if UI requires extra intermediate event names. | | P0 | Combined multi-account NAV | Closed. `DailyEquityPoint`, progress events, and metrics use aggregate stock + futures initial cash and total equity. | None. | -| P0 | Fixed-point execution money | Stock execution now freezes fee rates once and uses signed micro-yuan `i128` for gross amount, commission, stamp tax, transfer fee, strict budget checks, cash, liabilities, management fees, external flows and account units. Market indicators and return statistics remain `f64` outside the execution boundary. | Migrate position cost/PnL and the standalone futures cash ledger only after independent artifact and performance A/B gates. | +| P0 | Fixed-point execution money | Closed. Stock execution freezes fee rates once and uses signed micro-yuan `i128` for gross amount, commission, stamp tax, transfer fee, strict budget checks, cash, liabilities, management fees, external flows, account units, position lot cost and realized PnL. The standalone futures account uses the same fixed-point money boundary for cash, margin, transaction cost and daily PnL. Market indicators and return statistics remain `f64` outside the execution boundary. | None. | +| P0 | Bounded minute-data processing | Closed for the engine data model. Intraday history uses a sorted date index and scans backward only until the requested bar count is satisfied. Daily minute processing consumes a borrowed timestamp-ordered k-way merge and does not clone/materialize the full selected quote day before event dispatch. | Keep Source Lake and service clients batch-streamed; do not reintroduce whole-window row materialization. | | P1 | Futures trading parameter data source | Closed for engine-side trading-parameter ingestion/resolution via `futures_trading_parameters.csv` or component data. | Add more exchange metadata columns only when source data exposes them. | | P1 | Futures transaction cost decider | Closed. `FuturesTransactionCostModel` calculates by-money/by-volume open/close/close-today costs from trading parameters. | None. | | P1 | Futures settlement price mode | Closed. Engine supports configurable settlement price mode and resolves settlement/prev-settlement from factor fields with close/prev_close fallback. | Add dedicated settlement columns if the storage layer later separates them from factors. | @@ -58,6 +59,10 @@ futures path. Confirmed aligned areas: - [x] Fine-grained daily and minute execution quote strategy entrypoints. - [x] Stock broker fee, budget and cash-ledger arithmetic uses a micro-yuan fixed-point execution primitive; one-micro over-budget orders fail. +- [x] Stock position lots, realized/unrealized PnL, dividends and external cash + flows preserve fixed-point value conservation. +- [x] Futures cash, margin, transaction cost and daily realized/position PnL use + the fixed-point ledger. - [x] Scheduled actions evaluated against explicit intraday times. - [x] `update_universe`, `subscribe`, and `unsubscribe`. - [x] Intraday subscription guards at strategy API level; intraday execution uses minute quote semantics. @@ -73,6 +78,9 @@ futures path. Confirmed aligned areas: - [x] Trading-date range, previous-date, and next-date helpers. - [x] Phase-aware minute history cursor semantics matching the active bar or intraday execution quote callback. +- [x] Bounded intraday history lookup and borrowed minute quote streaming avoid + full-history scans and full-day quote clones while preserving timestamp + order and visibility boundaries. - [x] Suspension, ST, date-range price, active instrument, and instrument history helpers. - [x] Open-order status, unfilled quantity, final order lookup, average fill diff --git a/docs/fixed-point-minute-acceptance-20260831.md b/docs/fixed-point-minute-acceptance-20260831.md new file mode 100644 index 0000000..fb79e6b --- /dev/null +++ b/docs/fixed-point-minute-acceptance-20260831.md @@ -0,0 +1,75 @@ +# Fixed-Point and Minute-Stream Acceptance + +Acceptance date: 2026-08-31 +Engine commit: `cd116bc3ae77cac0989eb80185bb04d7440b8834` + +## Scope + +This acceptance separates execution precision from minute-data throughput. It +does not use a strategy-specific shortcut and does not change strategy, +matching, risk, slippage, commission, tax, or future-data semantics. + +## Fixed-Point Boundary + +- Execution money is signed micro-yuan `i128`. +- Stock gross amount, commission, stamp tax, transfer fee, cash, liabilities, + external cash flow, account units, position lot cost and PnL are fixed-point. +- Futures cash, margin, transaction cost, realized PnL and position PnL are + fixed-point. +- Market indicators and return statistics remain `f64`; conversion occurs only + at the execution-money boundary. +- One-micro-yuan budget overruns fail instead of being hidden by float epsilon. + +Verification command: + +```bash +cargo test -p fidc-core fixed -- --nocapture +``` + +Result: 8 passed, 0 failed. + +## Minute Data Boundary + +- `history_intraday_quotes_at` uses a sorted execution-date index and scans + backward until the requested bar count is satisfied. +- The active timestamp and `include_now` flag control visibility; later bars are + never visible. +- Daily minute execution consumes a borrowed k-way merge ordered by timestamp + and symbol. It does not clone the complete selected quote day before engine + dispatch. +- Execution quotes are released by trading date after the day finishes. + +Release benchmark command: + +```bash +cargo test -p fidc-core --test intraday_history_performance --release -- --ignored --nocapture +``` + +Observed on the local acceptance host: + +| Case | Workload | Result | +| --- | --- | --- | +| Bounded history | 200 queries over 60,000 rows | 0.000227 seconds, checksum 351450348000 | +| Full-day materialization | 5,000 iterations x 240 rows | 0.049361 seconds | +| Borrowed quote stream | 5,000 iterations x 240 rows | 0.012232 seconds | + +The materialized and streamed timestamp checksums were both +`2108693484000000`. The observed component speedup was about 4.04x. These +numbers are component evidence only and are not an end-to-end SLA. + +## Regression + +```bash +cargo test -p fidc-core --all-targets +``` + +Result: 528 passed, 0 failed, 1 ignored manual benchmark. This includes +execution-day risk, next-open open-price limits, minute timestamp visibility, +slippage, minimum commission, stamp tax, volume limits, corporate actions, +external cash-flow NAV treatment and futures account precision. + +## Deployment Gate + +This documentation-only correction does not require a service restart. Any +future Source Lake or engine deployment still requires the official managed +entrypoint and must fail closed while FIDC-managed factor work is active.