diff --git a/tests/unit/test_volume_ratio.py b/tests/unit/test_volume_ratio.py index 0d882a3..511d666 100644 --- a/tests/unit/test_volume_ratio.py +++ b/tests/unit/test_volume_ratio.py @@ -32,7 +32,26 @@ class _Con: return self -def test_compute_ratios_measures_and_skips_thin(): +def test_compute_ratios_measures_and_skips_thin(monkeypatch): + # Freeze the clock inside the stub's bar-date window. compute_ratios bails + # (`end <= start`) when UTC now-16min is before today's 08:00Z — true nightly + # from ~00:00-04:16 ET — so with hardcoded 2026-07-06 bars this test flaked at + # the date rollover regardless of the stub data. Pin a mid-session UTC clock. + import research.ingestion.volume_ratio as vr + from datetime import date as _date, datetime as _dt, timezone + + class _FrozenDT: + @staticmethod + def now(tz=None): + return _dt(2026, 7, 6, 18, 0, 0, tzinfo=tz or timezone.utc) + + class _FrozenDate: + @staticmethod + def today(): + return _date(2026, 7, 6) + + monkeypatch.setattr(vr, "datetime", _FrozenDT) + monkeypatch.setattr(vr, "date", _FrozenDate) r = compute_ratios(_Client(), ["GOOD", "DUST", "MISSING"]) assert r["GOOD"] == 25.0 # 12500 sip / 500 iex assert "DUST" not in r # sip sample below floor -> untrusted