Enrich M3 sim sub-specs with 11 discovered frameworks and 360:1 minimum speed

- M3 hub: add L3 invariant (360:1 minimum sim speed), six-horizon time table
- M3a: add Heston stochastic vol, rough volatility (fBM), HMM regime detection,
  DCC-GARCH copula, jump-diffusion; six-horizon mapping
- M3b: add Hegselmann-Krause bounded confidence, complex contagion, bandit-
  replicator hybrid, MFG (HJB+FP), pump-and-dump 3-type ABM; six-horizon mapping
- M3c: add six-horizon time table
- M3d: add Kolokoltsov adversarial (non-linear FP + WENO), DSMFG bilevel
  optimization, cross-chain adversarial arbitrage; six-horizon mapping
- M3e: add kinked lending rate model, DeXposure inter-protocol credit network,
  composable yield optimizer; six-horizon mapping
- M3f: add MFG for validator populations, six-horizon time table
- M3g: add Almgren-Chriss optimal execution, six-horizon mapping
- CLAUDE.md: add subagent productivity note

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Claude
2026-07-13 21:29:38 +00:00
parent 98a6f9a0b1
commit 1da2fa19c6
9 changed files with 412 additions and 146 deletions
@@ -2,69 +2,100 @@
## 1. Component
Market microstructure simulation: models **order flow, liquidity depth, slippage, spread dynamics,
and cross-exchange arbitrage** at the fastest time scales (tick-level to hourly). Pops here are
**market makers, takers, and arbitrageurs** interacting across multiple venues. The sim that
operates at the highest temporal resolution — where M3a provides statistical forecasts and M3c
models pool mechanics, M3g models the *plumbing* of how orders actually execute.
optimal execution, and cross-exchange arbitrage** at the fastest time scales. Pops here are
**market makers, takers, and arbitrageurs** interacting across multiple venues. Includes the
**Almgren-Chriss optimal execution framework** for minimizing market impact of large orders.
Operates at the highest temporal resolution — where M3a provides statistical forecasts and M3c
models pool mechanics, M3g models the *plumbing* of how orders actually execute, across **six
concurrent time horizons** at ≥ 360:1 speed.
## 2. Status / certainty
DESIGN-FIRST · ABSENT. Order-book microstructure theory C4 (established academic field);
DEX-specific microstructure C2 (emerging). Implementation C1.
DESIGN-FIRST · ABSENT. Order-book microstructure theory C4 (established). Almgren-Chriss
optimal execution C5 (industry standard since 2001; crypto adaptations validated 2023–2024,
Kurz CMC thesis). DEX-specific microstructure C2 (emerging). Implementation C1.
## 3. Language & location
TBD · `src/economy/sims/microstructure/`. Needs high-frequency data handling and event-driven
simulation. Rust, C++, or Python with optimized event loop.
TBD · `src/economy/sims/microstructure/`. Needs high-frequency data handling, event-driven
simulation, and Riccati equation solvers for optimal execution trajectories. Rust, C++, or
Python with optimized event loop.
## 4. Does / does-not
- **Does:** simulate order flow across venues (DEXs and CEXs); model bid-ask spread dynamics as a
function of inventory risk and adverse selection; simulate slippage curves for various order
sizes; model cross-exchange arbitrage opportunities and their decay; operate at **tick-level
resolution** (sub-second to minute); produce bounded predictions on execution quality, optimal
routing, and liquidity conditions.
sizes; solve **Almgren-Chriss optimal execution**:
$\min \int_0^T [\lambda \cdot x(t) \cdot \dot{x}(t) + \eta \cdot \dot{x}(t)^2] \, dt$
where $\lambda$ = permanent impact, $\eta$ = temporary impact, $x(t)$ = remaining order —
splits large orders across time to minimize market impact + timing risk; impact parameters
$\lambda, \eta$ re-estimated from order-flow streams every 10–30s; execution trajectory solved
via Riccati equations in <100ms; model cross-exchange arbitrage opportunities and their decay;
operate at **tick-level resolution** (sub-second to minute); produce bounded predictions on
execution quality, optimal routing, and liquidity conditions.
- **Does-not:** model protocol consensus (M3f); model macro token supply (M3e); model social
behavior (M3b); execute trades (Marketplace does).
## 5. Interface contract
- Implements `query(PredictionQuery) -> BoundedPrediction` per M3 hub.
- **Output bounds:** execution cost ranges and liquidity intervals.
Example: `{ value: 0.0034, lower_bound: 0.0018, upper_bound: 0.0052, confidence: 0.85,
time_horizon: "next_trade", sim_type: "market_microstructure" }` — expected slippage (%) for a
10 ETH market sell.
Example: `{ value: 12400, lower_bound: 8200, upper_bound: 18600, confidence: 0.78,
time_horizon: "1h", sim_type: "market_microstructure" }` — available depth (USD) within 50bps
of mid.
- **Output bounds:** execution cost ranges, liquidity intervals, optimal trajectory envelopes.
- **Time-horizon mapping** (all run concurrently, ≥ 360:1 speed):
| Horizon | Primary models | Update cadence |
|---------|---------------|----------------|
| Tick–hourly | Almgren-Chriss execution, slippage, spread, arb decay | Every tick |
| Daily | Liquidity regime, venue depth profiles | Hourly roll |
| Weekly | Cross-venue flow patterns, impact parameter drift | Daily roll |
| Monthly | Structural liquidity shifts, venue market share | Weekly roll |
| Annual | Microstructure regime (DEX vs CEX share evolution) | Monthly roll |
| 5-year | Venue topology evolution, structural impact trends | Quarterly roll |
- Examples:
`{ value: 0.0034, lower_bound: 0.0018, upper_bound: 0.0052, confidence: 0.85,
time_horizon: "next_trade", sim_type: "market_microstructure" }` — slippage (%) for 10 ETH.
`{ value: 12400, lower_bound: 8200, upper_bound: 18600, confidence: 0.78,
time_horizon: "1h", sim_type: "market_microstructure" }` — depth (USD) within 50bps.
`{ value: [0.3, 0.3, 0.2, 0.1, 0.1], lower_bound: null, upper_bound: null, confidence: 0.80,
time_horizon: "30min", sim_type: "market_microstructure" }` — Almgren-Chriss optimal execution
schedule (fraction per 6-min bucket for 100 ETH sell).
- **Prediction types:** `slippage_estimate`, `spread_forecast`, `depth_profile`,
`cross_venue_arb`, `optimal_execution_route`, `liquidity_score`.
`cross_venue_arb`, `optimal_execution_schedule`, `optimal_execution_route`,
`liquidity_score`, `impact_estimate`.
- Calibration: ingests `price_tick`, `dex_pool_state`, and `execution_fill` from M2.
## 6. Dependencies & stubs
- M2 Data Feeds — tick data and pool state; *stub:* canned order book snapshots.
- M3a Statistical — volatility estimates for Almgren-Chriss timing risk; *stub:* fixed vol.
- M3c AMM sims — pool mechanics for DEX venues; *stub:* fixed pool state.
- M3 Sims hub — lifecycle management; *stub:* manual init.
## 7. Invariants / laws
- **L1 (C4):** microstructure operates at the **highest temporal resolution** — predictions are
- **L1 (C5):** microstructure operates at the **highest temporal resolution** — predictions are
valid for seconds to hours, not days. Stale microstructure data is worse than no data.
- **L2 (C4):** slippage is a **function of order size and current depth** — not a fixed
- **L2 (C5):** slippage is a **function of order size and current depth** — not a fixed
percentage. The sim must model the non-linear relationship.
- **L3 (C3):** cross-venue arbitrage opportunities **decay** — the sim models the time-to-close
- **L3 (C5):** Almgren-Chriss impact parameters $\lambda, \eta$ are **estimated from live data**,
never hardcoded — crypto impact dynamics differ by asset, venue, and time-of-day.
- **L4 (C4):** cross-venue arbitrage opportunities **decay** — the sim models the time-to-close
of an arb opportunity, not just its existence.
- **L5 (C4):** optimal execution trajectories are **re-solved on every significant state change**
(vol spike, depth drop, regime transition) — a stale trajectory is worse than naive execution.
## 8. Build steps
1. Implement a simplified order-book simulator (limit orders, market orders, cancels).
2. Add spread dynamics (inventory-based market maker model).
3. Add slippage curves (order size → execution cost).
4. Add cross-venue arb detection and decay modeling.
5. Wire M2 tick data → calibration.
4. Implement Almgren-Chriss optimal execution (Riccati solver, impact estimation).
5. Add cross-venue arb detection and decay modeling.
6. Wire M2 tick data → calibration of impact parameters.
7. Wire M3a vol estimates → Almgren-Chriss timing risk component.
## 9. Tests
Slippage: larger orders produce greater slippage. Spread: spread widens under adverse selection.
Arb decay: detected arb opportunity closes over time. Depth: depth profile matches order book
state. Bounds: all outputs bounded. Resolution: predictions update at tick frequency.
Almgren-Chriss: optimal trajectory minimizes total cost vs. naive execution on backtest; impact
parameters update when market conditions change. Arb decay: detected arb opportunity closes over
time. Depth: depth profile matches order book state. Bounds: all outputs bounded. Resolution:
predictions update at tick frequency. Speed: sim advances ≥ 360:1.
## 10. Open items
- CEX order book data access (API limitations, costs).
- DEX-specific microstructure (AMM pools don't have order books — translate pool state to
equivalent depth/spread).
- Latency modeling (how fast can our traders actually reach an arb?).
- Almgren-Chriss extensions for crypto (volume-dependent variant? discrete block propagation?).
- Which venues to model initially.