fix(deribit): DVOL midnight — finestra 1D estesa a ieri+oggi

Alle 00:00 UTC Deribit non ha ancora costruito il candle 1D di oggi:
con start_date=oggi la response è vuota e il client tirava
McpDataAnomalyError ('neither latest nor candles'). Includendo ieri
nello start_date, candles[-1] resta valido come fallback.

Verificato sui dati raccolti: 3 fail consecutivi 2026-05-02/03/04 a
00:00 UTC su ETH, zero fail dal 2026-05-05 in poi (container
rebuildato in mezzo al periodo).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
root
2026-05-08 16:37:23 +00:00
parent a2e7a78f8a
commit 3aaa059417
+5 -2
View File
@@ -9,7 +9,7 @@ the ``core/`` algorithms stay in their preferred numeric domain.
from __future__ import annotations
import re
from datetime import UTC, datetime
from datetime import UTC, datetime, timedelta
from decimal import Decimal
from typing import Any, Literal
@@ -167,9 +167,12 @@ class DeribitClient:
) -> Decimal:
"""Return the latest DVOL value for ``currency``."""
when = (now or datetime.now(UTC)).astimezone(UTC)
# Window starts one day back so a tick fired exactly at 00:00 UTC
# — before Deribit has built today's 1D candle — still has
# yesterday's close to fall back on (see candles[-1] branch).
body = {
"currency": currency,
"start_date": (when.date()).isoformat(),
"start_date": (when.date() - timedelta(days=1)).isoformat(),
"end_date": when.date().isoformat(),
"resolution": "1D",
}