malkhut: CHASE mechanics FIXED + Flight9 learnings + TTL enforcement

1. CHASE mechanics (NOW WORKING):
   - CWM enforces TTL on open orders (auto-cancel when expired)
   - DSL CHASE produces PLACE with metadata={chase: True}
   - Action menu generates chase actions with wait_to_retry_ms TTL
   - OpenOrderState.gains ttl_ms field (0=no expiry, >0=auto-cancel)

2. TTL enforcement (CWM):
   - HftBacktestCWM: auto-cancels orders where age >= ttl_ms
   - MinimalCryptoLOBCWM: same TTL enforcement
   - This is how CHASE works: place→wait→auto-cancel→next step re-places

3. Flight9 learnings:
   - Slippage model gains trade_flow_intensity parameter
   - Book imbalance as proxy for trade arrival rate
   - Markout = quality concept documented

4. CHASE tests: 10 new tests covering TTL enforcement, cancel-retry cycle,
   max retries, DSL CHASE action, CMA codec integration

5. All 800+ tests pass
This commit is contained in:
Codex
2026-07-17 19:30:17 +02:00
parent bb229833d3
commit 4926ef6788
5 changed files with 125 additions and 1 deletions

View File

@@ -712,6 +712,19 @@ def _primitive_to_action(primitive: ActionPrimitive, state: MarketWorldState) ->
ttl_ms=int(primitive.duration_s * 1000), post_only=True,
)
elif at == ActionType.CHASE:
# Chase: place at target with short TTL. CWM auto-cancels when TTL expires.
# Next step the planner re-places at new offset (cancel-retry across CWM steps).
# Key: uses primitive.duration_s as the wait_to_retry_ms (how long before cancel).
ttl = int(primitive.duration_s * 1000) if primitive.duration_s > 0 else 100
return FulfilmentAction(
kind=ActionKind.PLACE, side=primitive.side, order_type=OrderType.LIMIT,
price_ticks_from_best=primitive.offset_ticks, qty_fraction=primitive.size_fraction,
ttl_ms=ttl, post_only=True,
metadata={"chase": True, "chase_offset": primitive.offset_ticks,
"chase_ttl_ms": ttl, "chase_target": "follow_price"},
)
return FulfilmentAction(ActionKind.NOOP, None, None, 0, 0.0, 0)