feat: add min hours-to-expiry filter on ops map (8-48h step 2)
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
from packages.domain.expiry import expiry_ms_from_ymd
|
||||
from packages.domain.expiry_filter import filter_rows_min_hours_to_expiry, hours_to_expiry_at
|
||||
|
||||
|
||||
def test_filter_min_hours():
|
||||
# 到期 260803 → 2026-08-03 08:00 UTC
|
||||
ymd = "260803"
|
||||
ems = expiry_ms_from_ymd(ymd)
|
||||
# 距到期 20h / 10h 的采样点
|
||||
ts_20h = ems - 20 * 3_600_000
|
||||
ts_10h = ems - 10 * 3_600_000
|
||||
rows = [
|
||||
{"ts_ms": ts_20h, "expiry_ymd": ymd, "side": "C"},
|
||||
{"ts_ms": ts_10h, "expiry_ymd": ymd, "side": "P"},
|
||||
]
|
||||
assert hours_to_expiry_at(ts_20h, ymd) == 20
|
||||
kept = filter_rows_min_hours_to_expiry(rows, min_hours=12)
|
||||
assert len(kept) == 1
|
||||
assert kept[0]["side"] == "C"
|
||||
Reference in New Issue
Block a user