Files
sanguo_vnpy_v2/tests/trader/test_shadow_snapshot_dedupe.py
T

20 lines
761 B
Python

"""#88 影子快照结算行去重:同日一行/空行情日期不写。"""
from sanguo_trader.shadow.runner import _should_write_balance
def test_empty_as_of_never_writes():
"""周末/未开盘 as_of='' → 不写(原实现每 30s 刷一行 date='' 垃圾)。"""
assert _should_write_balance("", "") is False
assert _should_write_balance("", "2026-08-14") is False
def test_same_day_written_once():
"""同一天只写第一行,后续轮询跳过。"""
assert _should_write_balance("2026-08-14", "") is True
assert _should_write_balance("2026-08-14", "2026-08-14") is False
def test_new_day_writes_again():
"""跨交易日再写一行(日净值语义)。"""
assert _should_write_balance("2026-08-17", "2026-08-14") is True