Phase 10e: Intrabar Execution + Gap Execution Realism - formal verifikativ abgeschlossen (Doku) - Rain Ocampo, 23.08.2026

This commit is contained in:
Rain Ocampo 2026-08-23 14:53:17 +00:00 committed by root
parent 69aecf2bb3
commit 4d421eab0d

View file

@ -116,10 +116,62 @@ Jede Tabelle FK auf `backtest_run(run_id) ON DELETE CASCADE`.
- **Modul-13: Optimization** — Image `optimization:0.1.0`, E2E-verifiziert (12/12 Punkte), **FREIGEGEBEN** (20.08.2026). Details: `modul-13-optimization.md`. - **Modul-13: Optimization** — Image `optimization:0.1.0`, E2E-verifiziert (12/12 Punkte), **FREIGEGEBEN** (20.08.2026). Details: `modul-13-optimization.md`.
- **V1.1-Strategie**: `trend_pullback_v1.1` (Image `backtesting:0.1.2`) — Spezifikation und Parameter: `trend-pullback-v1.1-spec.md`. - **V1.1-Strategie**: `trend_pullback_v1.1` (Image `backtesting:0.1.2`) — Spezifikation und Parameter: `trend-pullback-v1.1-spec.md`.
---
## Phase 10e — Intrabar Execution + Gap Execution Realism (23.08.2026)
Versionierung der Gap-/Intrabar-Semantik (KEIN separates `gap_execution_version`):
- Träger: `intrabar_policy` + `intrabar_policy_version = "intrabar_policy_v1"` im
`ExecutionContext` (`shared/historical/execution_context.py`). Dadurch ist die neue
Semantik eindeutig versioniert und ändert den V2-`run_hash` bei Policy-Wechsel
(PESSIMISTIC ≠ OPTIMISTIC → anderer run_hash).
- Legacy-Pfad bleibt unangetastet (PESSIMISTIC-Default, identisches Verhalten).
Intrabar-Policy (nur V2/BID_ASK): `PESSIMISTIC` | `OPTIMISTIC` | `STOP_FIRST` |
`TARGET_FIRST` | `TICK_RESOLUTION` | `UNKNOWN`. **Fail-closed** §18: `UNKNOWN`/
`TICK_RESOLUTION`/`BOGUS` → `ValueError`/`NotImplementedError`, kein Auto-Default.
Gap-Semantik (deterministisch, kein Lookahead):
- LONG: Stop/Target/Exit auf **BID**; SHORT auf **ASK**.
- Gap-Stop → Fill zum Gap-Open (schlechter, NICHT auf Stop-Level geclampt).
- Target-Gap → Fill zum besseren Gap-Open (nicht geclampt auf Target).
- Intrabar-Target füllt auf `target` (nicht low/high); Intrabar-Ambiguity (Stop UND
Target in einer Bar) per Policy (PESSIMISTIC→Stop, OPTIMISTIC→Target).
- Slippage wird adversial auf den tatsächlichen Fill (Trigger ≠ Market ≠ Final Fill
bei Gap + Slippage); Commission auf finalem Fill (rate × qty × fill pro Seite).
- **Kein Doppelspread/Slippage/Commission** (Vier-Ebenen-Trennung 10b/10c/10d/10e).
Audit (18 Felder, forensisch rekonstruierbar): `reason`, `intrabar_policy`,
`trigger_price`, `market_execution_price`, `exit_fill_price`, `gap_execution`,
`gap_open_price`, `execution_model`, `price_basis`, `spread_model`, `slippage_model`,
`slippage_value`, `cost_model`, `entry_fee`, `exit_fee`, `gross_pnl`, `net_pnl`
(verwendete vorhandene Feldnamen, keine künstlichen).
Verifikation 23.08.2026:
- Unit-Suite `test_phase10e_intrabar_gap.py`: 40/40 grün (Intrabar, Gap, Slippage
nach Gap, Commission auf Final Fill, BID/ASK-Seiten, Doppelzählung, Audit-18,
pathologische Fälle, 4 numerische PnL-E2E-Beispiele).
- Fixture-E2E (`test_phase10e_fixture_e2e.py`): 7/7 grün (A LONG Stop-Gap, B SHORT
Stop-Gap, C Intrabar PESSIMISTIC, D Intrabar OPTIMISTIC run_hash-Differenz,
E LONG Target-Gap, F SHORT Target-Gap, ENV-RESET); numerische Kette
Trigger → Gap-Open → Slippage → Final Fill → Commission → Gross → Net nachgewiesen.
- Regression Lauf 1 + Lauf 2: vollständig grün (M12 169 inkl. 10e, Phase5 20,
Phase6 14, Phase7 AJ Legacy-Hash `8a5760ae…`, M13 Shared AJ, M13 Compat 5/5).
- Legacy Production Smoke 2×: A==B==VORHER (run_hash `bc6e2553…`, data_hash
`d76a7549…`, net_pnl 196.586062, 1× LONG target). DB-Wahrheit verifiziert
(backtest_run/backtest_trade konsistent). Legacy unverändert durch Phase 10e.
- Production Gates M12+M13: `HISTORICAL_DATA_SOURCE`/`ALLOW_FIXTURE_DATA` UNSET.
- Deployt: `core/engine.py`, `core/service.py`, `api/schemas.py` (Container-Hashes
aktualisiert); `shared/historical/execution_context.py` + `pricing.py` unverändert.
--- ---
## Geändert ## Geändert
``` ```
Geändert von: Rain Ocampo Geändert von: Rain Ocampo
Datum: 23.08.2026
Grund: Modul-12-Doku um Phase 10e (Intrabar Execution + Gap Realism) ergänzt — Versionierung, Intrabar-Policy, Gap-Semantik, Audit-18, Verifikation, Deploy, Smoke, Production Gates.
```
```
Geändert von: Rain Ocampo
Datum: 20.08.2026 Datum: 20.08.2026
Grund: Modul-12-Backtesting als FREIGEGEBEN markiert (deployt + E2E verifiziert: deterministisch, kein Lookahead, Stop/Target/Gap, LONG/SHORT, run_hash+data_hash). Grund: Modul-12-Backtesting als FREIGEGEBEN markiert (deployt + E2E verifiziert: deterministisch, kein Lookahead, Stop/Target/Gap, LONG/SHORT, run_hash+data_hash).
``` ```