From 3aaa05941785c83d74818008abf32c0846f6bb71 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 8 May 2026 16:37:23 +0000 Subject: [PATCH] =?UTF-8?q?fix(deribit):=20DVOL=20midnight=20=E2=80=94=20f?= =?UTF-8?q?inestra=201D=20estesa=20a=20ieri+oggi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- src/cerbero_bite/clients/deribit.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cerbero_bite/clients/deribit.py b/src/cerbero_bite/clients/deribit.py index 88ac2a1..cd5b30b 100644 --- a/src/cerbero_bite/clients/deribit.py +++ b/src/cerbero_bite/clients/deribit.py @@ -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", }