feat(analysis): _expected_ticks per finestre */15 allineate
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -93,3 +93,29 @@ class ChainAuditReport:
|
||||
iv_null_count: int = 0
|
||||
iv_null_pct: Decimal = Decimal("0")
|
||||
depth_zero_pct: Decimal = Decimal("0")
|
||||
|
||||
|
||||
def _expected_ticks(since: datetime, until: datetime) -> int:
|
||||
"""Number of `*/15` ticks in ``[since, until)`` aligned to wall clock.
|
||||
|
||||
A tick is any UTC instant where ``minute % 15 == 0``. The first
|
||||
tick at or after ``since`` is computed by rounding ``since`` up;
|
||||
every subsequent tick is +15 minutes. The window is half-open on
|
||||
the right.
|
||||
"""
|
||||
if until <= since:
|
||||
return 0
|
||||
# Round `since` up to the next */15 boundary.
|
||||
minute = since.minute
|
||||
remainder = minute % _TICK_INTERVAL_MIN
|
||||
if remainder == 0 and since.second == 0 and since.microsecond == 0:
|
||||
first_tick = since
|
||||
else:
|
||||
bump = _TICK_INTERVAL_MIN - remainder
|
||||
first_tick = (since + timedelta(minutes=bump)).replace(
|
||||
second=0, microsecond=0
|
||||
)
|
||||
if first_tick >= until:
|
||||
return 0
|
||||
span = until - first_tick
|
||||
return int(span.total_seconds() // (_TICK_INTERVAL_MIN * 60))
|
||||
|
||||
Reference in New Issue
Block a user