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", }