Phase 4 hardening: dealer-gamma + liquidation-heatmap entry filters
Integra due nuovi filtri dal pacchetto quant indicators rilasciato in Cerbero_mcp (commit a13e3fe). 335 test pass, mypy strict pulito, ruff clean. Filtri (§2.8 — nuovo): - dealer-gamma: blocca entry quando total_net_dealer_gamma < dealer_gamma_min (default 0). Long-gamma regime favorisce credit spread (vol-suppressing dealer flow); short-gamma flow lo amplifica ed è da evitare. - liquidation-heatmap: blocca entry quando il segnale euristico di cerbero-sentiment riporta long o short squeeze risk = "high" (cluster di liquidations imminenti entro 24h). Entrambi sono best-effort: se il tool MCP fallisce o restituisce dati anomali l'entry_cycle popola EntryContext con None e validate_entry salta il gate per non bloccare entry su problemi infrastrutturali. Wrapper: - DeribitClient.dealer_gamma_profile_eth → DealerGammaSnapshot. - SentimentClient.liquidation_heatmap → LiquidationHeatmap con property has_high_squeeze_risk. Schema: - EntryConfig.dealer_gamma_min, dealer_gamma_filter_enabled, liquidation_filter_enabled. - EntryContext.dealer_net_gamma, liquidation_squeeze_risk_high opzionali. - strategy.yaml: nuovi campi documentati con commento + hash ricalcolato (4c2be4c5...). Documentazione: - docs/04-mcp-integration.md riscritto al modello attuale (HTTP REST, no mcp SDK, no memory/brain-bridge, place_combo_order documentato, environment_info al boot). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -37,6 +37,13 @@ class EntryContext(BaseModel):
|
||||
next_macro_event_in_days: int | None
|
||||
has_open_position: bool
|
||||
|
||||
# Quant filters (§2.8). Both are optional: when the snapshot
|
||||
# collector cannot reach the underlying MCP tool the orchestrator
|
||||
# passes ``None``, and ``validate_entry`` skips the gate to avoid
|
||||
# blocking entries on infrastructure issues.
|
||||
dealer_net_gamma: Decimal | None = None
|
||||
liquidation_squeeze_risk_high: bool | None = None
|
||||
|
||||
|
||||
class EntryDecision(BaseModel):
|
||||
"""Result of :func:`validate_entry`. ``reasons`` holds *all* blocking reasons."""
|
||||
@@ -103,6 +110,27 @@ def validate_entry(ctx: EntryContext, cfg: StrategyConfig) -> EntryDecision:
|
||||
f"{entry_cfg.eth_holdings_pct_max})"
|
||||
)
|
||||
|
||||
# §2.8: dealer-gamma regime gate. Skip the cycle when dealers are
|
||||
# net short gamma (vol-amplifying flow) — selling premium during a
|
||||
# short-gamma regime maximises path-dependent loss.
|
||||
if (
|
||||
entry_cfg.dealer_gamma_filter_enabled
|
||||
and ctx.dealer_net_gamma is not None
|
||||
and ctx.dealer_net_gamma < entry_cfg.dealer_gamma_min
|
||||
):
|
||||
reasons.append(
|
||||
f"dealer short-gamma regime "
|
||||
f"({ctx.dealer_net_gamma} < {entry_cfg.dealer_gamma_min})"
|
||||
)
|
||||
|
||||
# §2.8: liquidation-pressure gate. Skip when the heuristic flags an
|
||||
# imminent squeeze on either side.
|
||||
if (
|
||||
entry_cfg.liquidation_filter_enabled
|
||||
and ctx.liquidation_squeeze_risk_high is True
|
||||
):
|
||||
reasons.append("imminent liquidation squeeze risk")
|
||||
|
||||
return EntryDecision(accepted=not reasons, reasons=reasons)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user