malkhut(docs): fill quality documentation — README, integration, OB study

README: Fill Quality section (core optimization target, metrics, reward
function, PerformanceMatrix, CMA-ES integration)

HftBacktestCWM integration doc: FillQuality dataclass, fill_value_score
computation, reward function weighting, PerformanceMatrix tracking

OB microstructure study: Section 13 — Fill Quality Optimization,
per-asset expectations, optimization strategy, connection to OB dynamics

Fill quality is MALKHUT's core aim: the system learns to get better fills
(faster, better-priced, less adverse selection) across regimes and venues.
This commit is contained in:
Codex
2026-07-15 15:36:22 +02:00
parent 618ad723e3
commit 619966605e
3 changed files with 140 additions and 0 deletions

View File

@@ -343,3 +343,52 @@ Example for DOGE ($22K amplitude, alpha=1.00):
BTC allows $100K orders with <1 bps slippage. DOGE requires $1K orders for
the same. Position sizing must account for the book's capacity, not just
the strategy's signal.
## 13. Fill Quality Optimization (MALKHUT Core)
MALKHUT is an execution improvement engine. Fill quality IS the primary aim.
### Fill Quality Metrics
For each CWM transition, MALKHUT computes:
- **slippage_bps**: aggressive fills — how far from mid?
- **price_improvement_bps**: passive fills — how much better than touch?
- **levels_consumed**: queue depth of fill
- **post_fill_adverse_bps**: price movement after fill (negative = adverse)
- **fill_value_score**: composite = quality - adverse * 0.5
### How This Connects to the OB
The OB microstructure directly determines fill quality:
| OB Characteristic | Impact on Fill Quality |
|-------------------|----------------------|
| **Depth at touch** | More depth = more fill opportunities for passive orders |
| **Spread** | Tighter spread = smaller price improvement possible |
| **Depth decay (alpha)** | Steeper decay = fills walk the book faster = higher slippage |
| **Cancel/fill ratio** | Higher ratio = more queue churn = harder to get fills |
| **MM pull speed** | Faster pull = stale quotes less likely = harder to snipe |
| **Book fragility** | During stress, depth drops 70-95% = fills at worse prices |
### Per-Asset Fill Quality Expectations
| Asset | Expected Fill Quality | Why |
|-------|----------------------|-----|
| BTC | Excellent | Deep book, tight spread, fast MM re-quote |
| ETH | Good | Similar to BTC, slightly thinner |
| SOL | Moderate | Mid-depth, moderate spread |
| DOGE | Poor | Thin book, wide spread, slow MM |
| ADA | Poor | Thin book, wide spread |
### Optimization Strategy
1. **Venue selection**: choose venues with better fill quality (Binance > BingX)
2. **Order type selection**: use POST_ONLY on tight-spread assets, MARKET on thin-spread
3. **Offset optimization**: CMA-ES learns optimal offset per (asset, regime, venue)
4. **Size optimization**: CMA-ES learns optimal size per (asset, regime, venue)
5. **Timing optimization**: CMA-ES learns when to quote vs when to wait
The PerformanceMatrix tracks `avg_fill_value_score` per (regime, strategy, venue),
enabling the system to learn: "In this regime, on this venue, this strategy
achieves the best fill quality."