diff --git a/prod/docs/JEV_OB_STATE_OUTSMART_NOTES.md b/prod/docs/JEV_OB_STATE_OUTSMART_NOTES.md new file mode 100644 index 0000000..75a51d8 --- /dev/null +++ b/prod/docs/JEV_OB_STATE_OUTSMART_NOTES.md @@ -0,0 +1,87 @@ +# Could Jev Be Adapted to Outsmart the Book? (OB‑state quoting, fees & fill) + +**Read‑only note. No data/CH/HZ touched.** Captures the reusable mapping of jev's +`buildState` onto FLIGHT's fill‑prediction lattice (SRC‑01) + the EV gate, so a future +session does not re‑derive it. + +## TL;DR +- jev's *placement* is naive: fixed `quoteInsideTicks=1`, fixed `tradeSizeMon=200`, one + post‑only order **every block regardless of book state**. It earns the tick when a taker + crosses it and loses the tick‑gas + opportunity cost when it does not. +- "Outsmart the book" = predict fill probability from book **motion** (not the snapshot), + gate `rest vs take` by the EV break‑even, size by the impact‑size curve, and **modify‑to‑the‑touch + (fee‑free) instead of cancel+place**. All of that already exists in FLIGHT. +- jev's `buildState` already assembles the *right inputs*; the missing piece is a + **learned fill gate** over them. A general structured‑output LLM is the **wrong** tool + — SRC‑01 shows a narrow learned factor lattice (the activity family + EWMA eigen) + **beats** HD and a general LLM, and is far cheaper/faster. jev's value here is the + clean state assembly + serialized cadence, not its oracle. + +## 1. jev's book state — what it already sees (`model.ts` buildState) +`bookImbalance`, `spreadBps`, `depthBps{10/25/50}`, top‑5 levels, `returnsBps{1/5/20/100}` +(from a 400‑block `mids` window), `recentMids` (every 5th block over `horizonBlocks`), +`taker` flow summary (`cvdMon`, `vwap`, `lastSide`). **The state is OB‑state rich.** +The placement policy just ignores almost all of it. + +## 2. SRC‑01 (FLIGHT's fill lattice) — what "outsmart" actually means +Source: `EXEC_SOA_SUPERSESSION_AUDIT_20260808.md` §SRC‑01. Corpus 472 factors / 356,282 rows +/ 8 assets / base fill rate 0.453 / metric = OOS within‑asset quintile lift (pp). + +**The activity family dominates everything ("a book that is moving fills you"):** +`n_chg_60 +18.54`, `q_path_60 +18.21`, `q_path_30 +17.10`, `n_chg_30 +16.67`, +`fs_imbalance +16.42`, `q_range_60 +15.81`, `q_range_300 +14.98`, `q_range_15 +14.06`, +`q_range_30 +13.63`. **Nothing in the OB snapshot comes close.** + +- EWMA bank: `eig_ew_w750_lambda_max +11.4 → +12.5` at every span (10…1000) — robust, not an artifact. +- `|vel_div|` (the NG7 incumbent) = **+5.02** — beaten 3.7× by the activity family, 2.5× by the EWMA eigen family. Velocity‑only underperforms. +- **Impact‑size curve peaks at 200–2000 notional, collapses by 50,000.** Peak brackets **BLUE's actual $16,290 notional** — i.e. a resting offer *just* large enough to be reached by a ~30 s touch. +- HD at 39 factors = **+20.73** vs best single **+19.17** — *barely* ahead; full 472 killed by memory; verdict OPEN. → a big general model does not pay off here. +- New/odd: `oi_usd −3.77` (−OI ⇒ more pickup); **fewer book levels ⇒ more pickup** (thin‑book). Sporadic winner `eig_regime_signal +4.72` (z=+15.0, n=32,023) — well‑powered. + +### jev state → SRC‑01 factor mapping +| jev `buildState` | SRC‑01 factor(s) | "outsmart" lever | +|---|---|---| +| `returnsBps{1/5/20/100}`, `mids`(400), `recentMids` | `n_chg_60/30`, `q_path_60/30`, `q_range_*` | REST only when book is *moving in your direction* (p_fill high) | +| `bookImbalance`, `depthBps{10/25/50}` | `fs_imbalance`, thin‑book effect | pick side where imbalance + thin depth ⇒ higher pickup | +| (computed) book‑return eigen (EWMA bank) | `eig_ew_w750_lambda_max` | **highest‑value add** — jev doesn't compute this today | +| `tradeSizeMon=200` (fixed) | impact‑size curve | SIZE to the curve peak (200–2000 notional); don't sit deep past reachability | +| `quoteInsideTicks=1` (fixed) | (none — snapshot‑blind) | price inside touch *dynamically* by p_fill, not by fixed 1 tick | +| n/a | `oi_usd` | avoid high‑OI windows (reduces pickup) | + +## 3. The EV gate that decides rest‑vs‑take (the "avoid fees" hinge) +`EV_rest − EV_take = p_fill × (Δ + offset) − (1 − p_fill) × s`, break‑even `p* = s / (Δ + s)`. +`Δ = taker − maker = 4.50 − 1.50 = 3.00 bp` (measured, HL mainnet). `s` = realised cost of a +maker miss (delay slippage + adverse drift). + +- **Rest (maker, 1.5 bp rebate / capture the tick) only when `p_fill > p*`.** Below `p*`, + you pay the ~300 ms block gas/wait and likely sit unfilled — that is the fee/opportunity cost jev + currently burns every block unconditionally. +- jev's replace‑every‑block **cancel+place** is *two* signed actions per cycle on Kuru; on + HL that erodes the rate budget (`HlVenueAdapter` 1 req / $1 USDC traded — the #59 ledger). + The fee‑free path to "outsmart + avoid fees" is **atomic modify‑to‑the‑touch** + (FLIGHT `EntryReprice`, same cloid, ≤1/bar) — which jev does NOT have; jev cancel+places. + +## 4. Why a structured‑output LLM is the wrong tool here +- The signal is **exactly computable**: book‑change counts, path/range, imbalance, EWMA eigen — + all cheap floats from the depth stream. The study proves a narrow learned lattice + (activity family) **beats** HD and would beat a general LLM, at milliseconds and zero gas. +- An LLM per‑cadence call is 50–200 ms of **added** latency against a venue already + budget‑throttled (1 req/$1 USDC) and single‑writer‑lanned (ASEx P0‑P4). It is drag, not thrust. +- jev's structured output is rightly confined to the **direction call** (where BLUE already + owns the intent lane) — keep it there. The book‑outsmarting should be a **deterministic + learned fill gate** over jev‑style state. + +## 5. Adaptation recipe (jev's cadence + FLIGHT's gate) +1. Keep jev's `buildState` (it is already OB‑state rich) + the serialized post‑only cadence. +2. **Add** the activity‑family + EWMA‑eigen features (notably `eig_ew_w750_lambda_max`, today absent). +3. Gate rest/take via the EV `p*` (`p_fill > p*` → rest; else take or skip) instead of + "always rest 1 tick inside." +4. Size by the impact curve (200–2000 notional peak; BLUE at $16.3k is the upper end of reachability). +5. **Replace cancel+place every block with atomic modify‑to‑the‑touch** (FLIGHT `EntryReprice`, + `offset_ticks=1`, `post_only=True`) to spare the HL rate budget — this alone is a big fee avoider. +6. Reuse FLIGHT's `ExecControl.max_spread_bps` gate (exec_router `plan_entry`) — no point resting when spread > 5 bp. + +**Net:** yes, jev‑style OB‑state quoting can outsmart the book; FLIGHT already built the +outsmarting (SRC‑01 + EV gate + atomic modify). The adaptation is grafting jev's clean +buildState + post‑only cadence onto that deterministic learned gate — **not** adding an LLM to the +placement path.