Commit Graph

5 Commits

Author SHA1 Message Date
Codex
bb229833d3 malkhut: Flight9 learnings — markout=quality, queue×flow, depth-for-size
Fable's Flight9/BLUE generalizable features incorporated:

1. Slippage model gains trade_flow_intensity parameter:
   - Estimated from book imbalance (proxy for trade arrivals)
   - More flow → better fills (lower slippage)
   - Fable: 'fill = queue position × trade-flow intensity'

2. Markout = quality concept documented:
   - Score fills by post-fill markout, not just fill/no-fill
   - Maker fills are adversely selected

3. Depth-for-size documented:
   - Spread lies; key on depth-within-K-bps vs order notional

4. Measured fees:
   - BingX maker=2.00bp, taker=5.016bp (over 1,455 fills)
   - BingX commission = NEGATIVE (debit)

5. OB study updated with Flight9 learnings
2026-07-17 16:18:43 +02:00
Codex
8857daedfa malkhut: urgency-driven maker/taker + calibrated slippage + chase + docs 2026-07-17 10:16:55 +02:00
Codex
619966605e 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.
2026-07-15 15:36:22 +02:00
Codex
4aeadf1aae docs: hftbacktest CWM integration design — drop-in LOB backend
Architecture:
  hftbacktest replaces _fill_from_levels() + manual book updates
  Everything above transition() stays the same

What changes:
  - HftBacktestCWM: new class implementing CodeWorldModel protocol
  - transition(): submit/cancel via hftbacktest, convert state back
  - fill model: ProbQueueModel (queue-position-aware)
  - latency: interpolated from historical data

What does NOT change:
  - Planner (SM-MCTS, EXP3, Thompson, etc.)
  - Counterparty ecology (ToxicTaker, PassiveMaker, etc.)
  - Risk gate (all 6 checks)
  - CMA-ES trainer
  - PerformanceMatrix
  - Reward function (same PnL + adverse selection + risk)
  - Action menu, FulfilmentAction, ScenarioFactory
  - ALL existing tests

Integration: 3 steps, zero core changes:
  1. Create malkhut/cwm/hft_cwm.py
  2. Swap cwm_factory in PolicyEvaluator
  3. Done
2026-07-14 18:37:41 +02:00
Codex
943b3ef985 docs: order book microstructure study — 12 sections, 13 assets
Comprehensive OB study compiled from live Binance/BingX data + academic
literature (Bouchaud, Cont/Stoikov, Cartea/Jaimungal):

1. Depth power-law decay: D(d) = A * d^(1-alpha), per-asset params
2. Spread profiles: normal + stress multipliers for all 13 assets
3. Order flow: arrival rates, cancel/fill ratios, size distributions
4. Market maker behavior: inventory limits, pull speed, margins
5. Volatility regimes: GARCH params, half-lives, crisis multipliers
6. Intraday patterns: peak/trough hours, session analysis
7. Cross-asset correlations: normal vs crash behavior
8. BingX-specific: spread/depth/latency/fees vs Binance ratios
9. Book fragility & cascade dynamics: flash crash anatomy
10. Retail vs institutional composition
11. Funding rates: per-asset means, std, positive%
12. Expected slippage model
2026-07-14 18:17:15 +02:00