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:
@@ -92,6 +92,8 @@ class _MarketSnapshot:
|
||||
macro_days_to_event: int | None
|
||||
eth_holdings_pct: Decimal
|
||||
portfolio_eur: Decimal
|
||||
dealer_net_gamma: Decimal | None
|
||||
liquidation_squeeze_risk_high: bool | None
|
||||
|
||||
|
||||
async def _gather_snapshot(
|
||||
@@ -148,6 +150,15 @@ async def _gather_snapshot(
|
||||
portfolio_t: asyncio.Task[Decimal] = asyncio.create_task(
|
||||
portfolio.total_equity_eur()
|
||||
)
|
||||
# The two quant filters are best-effort: if the underlying tool
|
||||
# fails the orchestrator passes ``None`` and validate_entry skips
|
||||
# the gate (see core/entry_validator §2.8).
|
||||
dealer_t: asyncio.Task[Decimal | None] = asyncio.create_task(
|
||||
_safe_dealer_gamma(deribit)
|
||||
)
|
||||
liquidation_t: asyncio.Task[bool | None] = asyncio.create_task(
|
||||
_safe_liquidation_squeeze(sentiment)
|
||||
)
|
||||
|
||||
await asyncio.gather(
|
||||
spot_t,
|
||||
@@ -159,6 +170,8 @@ async def _gather_snapshot(
|
||||
macro_t,
|
||||
holdings_t,
|
||||
portfolio_t,
|
||||
dealer_t,
|
||||
liquidation_t,
|
||||
)
|
||||
return _MarketSnapshot(
|
||||
spot_eth_usd=spot_t.result(),
|
||||
@@ -170,9 +183,27 @@ async def _gather_snapshot(
|
||||
macro_days_to_event=macro_t.result(),
|
||||
eth_holdings_pct=holdings_t.result(),
|
||||
portfolio_eur=portfolio_t.result(),
|
||||
dealer_net_gamma=dealer_t.result(),
|
||||
liquidation_squeeze_risk_high=liquidation_t.result(),
|
||||
)
|
||||
|
||||
|
||||
async def _safe_dealer_gamma(deribit: DeribitClient) -> Decimal | None:
|
||||
try:
|
||||
snap = await deribit.dealer_gamma_profile_eth()
|
||||
except Exception:
|
||||
return None
|
||||
return snap.total_net_dealer_gamma
|
||||
|
||||
|
||||
async def _safe_liquidation_squeeze(sentiment: SentimentClient) -> bool | None:
|
||||
try:
|
||||
heatmap = await sentiment.liquidation_heatmap("ETH")
|
||||
except Exception:
|
||||
return None
|
||||
return heatmap.has_high_squeeze_risk
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Helpers
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -321,6 +352,8 @@ async def run_entry_cycle(
|
||||
eth_holdings_pct_of_portfolio=snap.eth_holdings_pct,
|
||||
next_macro_event_in_days=snap.macro_days_to_event,
|
||||
has_open_position=False,
|
||||
dealer_net_gamma=snap.dealer_net_gamma,
|
||||
liquidation_squeeze_risk_high=snap.liquidation_squeeze_risk_high,
|
||||
)
|
||||
decision = validate_entry(entry_ctx, cfg)
|
||||
inputs = {
|
||||
|
||||
Reference in New Issue
Block a user