var - backtest related and spy runbook

This commit is contained in:
2026-08-28 15:10:09 -04:00
parent dd8e4cca0c
commit 81ae138a00
16 changed files with 948 additions and 94 deletions

53
spy-0dte-scalp-runbook.md Normal file
View File

@@ -0,0 +1,53 @@
# SPY 0DTE Scalp Runbook — E2E Fast Path
*Built from live execution 2026-08-28 (spy-1787942969793, closed un-filled at 3:00 wall). Companion lessons live in MEMORY.md: record_plan v2 schema, arm-card flow, ttg-options endpoint patterns.*
## The speed rule
**Never discover inside a trade window.** Design + record the plan BEFORE the intended entry window; arm = one line. First-ever run took ~7 min for design→record (3 schema validation iterations) + unresolved arm-card surfacing = whole window lost. With this runbook: **~2 min to recorded plan, one line to arm.**
## 1. Pre-stage (do this 5+ min before the window)
- Fresh SPY snapshot (built-in `snapshot` tool) — price, day OHLC, VWAP.
- Direction call: price vs VWAP + day-low/high structure. Trend-day tape → trade the break (continuation), not the bounce. Mid-range chop → stand down.
- Liquidity check (both expiries, Friday rule):
- `ttg-options` → `options_snapshot_chain`, params: `underlyingAsset: "SPY"`, `contract_type: "put"|"call"`, `expiration_date: "2026-08-28"` (EXACT string; range objects `{"gte":...}` = HTTP 500), `limit: 250`, `sort: "strike_price"`.
- 0DTE near-money: 1–2¢ spreads, 300–600K vol = elite. Next-week: 2–3¢ spreads but premium ~$4 → +20% in 15 min needs ~$1.60 SPY move vs ~$0.30 on 0DTE. 0DTE is the 15-min vehicle; next-week is for plays/swings.
- Vehicle pick: ATM-ish strike, delta −0.4 to −0.5 at expected trigger price, spread ≤ 2¢.
## 2. Record the plan (exact verified v2 shape)
`ttg_trade_workflow_record_plan` — template (from the call that validated):
```
brokerId: "tos-paper", connectedBrokerPackId: "tos-paper",
accountCode: "D-67336185" // 185; "D-67336186" = 186
assetClass: "option", symbol: "SPY", side: "buy",
tradeStyle: "scalp",
instrumentRef: {symbol: ".SPY260828P769", strike: 769, type: "put",
expiration: "2026-08-28", underlying: "SPY",
occ: "O:SPY260828P00769000"}, // MUST be object, not string
levels: {
entry: {zone: {low: 0.76, high: 0.92}, type: "limit", minBidSize: 50}, // premium zone
stop: {offset: 0.18}, // points from fill (premium pts for options)
targets: [{offset: 0.20, portionPct: 67}, {offset: 0.40, portionPct: 33}], // max 2
timeStopSec: 900, // REQUIRED for scalp/day; in-trade from fill
breakevenAfterT1: true
},
risk: {maxDollars: 70}, // engine computes qty = maxDollars/(offset×100) — NEVER send qty
timeLimitSec: 780, // ENTRY WINDOW seconds (NOT the time stop)
rationale: "≥40 chars — put SPY-level triggers, invalidations, hard walls, order-safety directives here"
```
Validation gotchas (each cost an iteration): `tradeStyle` not `style`; no top-level entry/stop/target/qty; `instrumentRef` object not string; engine enforces **R:R > 1 — every target offset must exceed the stop offset**.
Response: planId `spy-<epoch-ms>`, status draft in PLANS/. SPY-level triggers go in rationale.
## 3. Arm (the one unverified link — TEST FIRST, outside a live window)
Record response says: "Propose an arm trade-action card — the app runs the pack preflight, verifies the stream, starts the preview belt. Do NOT call record_preflight (cockpit packs), do NOT start belt jobs yourself."
- Arm card does NOT auto-render in the cockpit UI (confirmed 2026-08-28: cockpit open+connected, no card).
- **Working hypothesis:** arm via the Live Trading window's own MARI chat — type `arm <planId>`. Cockpit agent (locked to the pack) proposes the Arm card → tap Arm (preflight auto-runs) → tap Enter.
- NEVER fake arming from main chat (`update_plan status:"open"` skips preflight/stream verify — dangerous). Main-window MARI cannot arm; cockpit orchestrator owns execution.
## 4. Manage (standing protocol — member directives, encode in rationale every time)
1. On fill: verify BOTH working and filled orders. Stop must read **SELL TO CLOSE <qty>** — never sell-to-open, never a short entry.
2. T1 fills → scale stop to remaining qty (+ breakevenAfterT1 moves it to BE). T2/stop-out → **cancel ALL working orders the instant flat.** Working + filled checked both after every event. No orphans, ever.
3. Walls: `timeStopSec` from fill + explicit wall-clock hard flat in rationale. Bail on tape deterioration before the stop (slow grind back = failed setup).
4. Pre-entry invalidations: structure reclaim / VWAP reclaim / no trigger by window close → no trade. **Stale plan = close clean, never chase** (2026-08-28: closed un-filled at 3:00 wall, $0 cost).
## 15-min target math (10–25% premium band)
- 0DTE ATM-ish premium P, delta Δ: +20% ≈ 0.20·P / Δ SPY move. At P≈$0.85, Δ≈−0.50 → ~$0.34 SPY. Routine in 15 min on a break.
- Engine R:R rule forces target offset > stop offset: size stop −18 to −22% and T1 +24 to +26% to stay inside the band AND clear R:R>1 (verified combo: stop 0.18 / T1 0.20 / T2 0.40 on ~$0.84 fill).