diff --git a/sanguo_portfolio/strategies/channel_test.py b/sanguo_portfolio/strategies/channel_test.py index a6e09b0..2506745 100644 --- a/sanguo_portfolio/strategies/channel_test.py +++ b/sanguo_portfolio/strategies/channel_test.py @@ -97,16 +97,21 @@ class ChannelTestStrategy: b.set_option("use_real_price", True) b.set_option("avoid_future_data", True) if self._on_demand(): - # 随启随验:只注册一个"启动后约90秒"的探针任务。必须经 facade.run_daily - # 注册而非直接调用——回调才会收到 B2 包装的代理 context(实例预算视图), + # 随启随验:只注册一个探针任务。必须经 facade.run_daily 注册而非 + # 直接调用——回调才会收到 B2 包装的代理 context(实例预算视图), # 绕过它探针就测不到定寸虚拟化。重启实例(停止→启动)即再验一轮。 - # 盘前/盘后/周末重启不注册(锚点在时段外=盘后真单挂柜台,09-01 实锤)。 + # 锚点策略:盘中重启锚 now+90s(快验);盘外重启锚固定 9:35—— + # 09-01 实锤 now+90s 落盘外=16 笔真单挂柜台,而 5d0a0bf 初版 + # 「盘外不注册」在 09-02 被 dev 巡检实锤副作用:轮换按运维规则放 + # 23:05 后 → 每次 boot 都盘外 → 永不注册 → 测试通道停摆 + # (live_18/22 零任务,四场景至少停一天)。 probe_at = _now() + timedelta(seconds=90) if not _in_trading_session(probe_at): logger.warning( - "[PROBE] 重启于非交易时段(探针锚定 %s),跳过随启随验注册" - "——防盘后挂单排队次日集合竞价;下次盘中重启再验", + "[PROBE] 重启于非交易时段(探针锚定 %s),改锚固定时刻 9:35" + "——防盘后挂单排队次日集合竞价,同时保住测试通道每日在验", probe_at.strftime("%H:%M")) + b.run_daily(self.probe_all, "9:35") return b.run_daily(self.probe_all, probe_at.strftime("%H:%M")) diff --git a/tests/portfolio/test_channel_test.py b/tests/portfolio/test_channel_test.py index 368f199..2080ec0 100644 --- a/tests/portfolio/test_channel_test.py +++ b/tests/portfolio/test_channel_test.py @@ -237,9 +237,14 @@ def test_probe_all_skips_out_of_session(monkeypatch, caplog): assert any("非交易时段" in r.message for r in caplog.records) -def test_initialize_on_demand_after_hours_skips_registration(monkeypatch, caplog): - """盘后重启(live env)不注册随启随验——run_daily 锚点落在时段外必跳过, - 否则 16 笔真单挂柜台排队次日集合竞价(09-01 18:48 轮换实锤)。""" +def test_initialize_on_demand_after_hours_registers_fixed_anchor(monkeypatch, caplog): + """盘后重启(live env)改锚固定盘中时刻 9:35,而非放弃注册。 + + 09-01 18:48 轮换实锤「now+90s 落盘外=16 笔真单挂柜台」后,5d0a0bf 修成 + 盘外不注册;09-02 dev 巡检实锤其副作用:运维规则轮换放 23:05 后 → 每次 + boot 都盘外 → 永不注册 → 测试通道四场景停摆(live_18/22 零任务)。修=盘外 + boot 锚定固定 9:35(历史主调仓时刻,probe_all 一轮覆盖 rotate/T1/swap), + 既有盘后挂单风险由锚点固定+执行侧守卫双重消除。""" monkeypatch.setenv("SANGUO_LIVE_STRATEGY", "channel_test") ct._now = lambda: datetime(2026, 9, 1, 18, 48) # type: ignore[assignment] registered: list = [] @@ -254,7 +259,7 @@ def test_initialize_on_demand_after_hours_skips_registration(monkeypatch, caplog config=ChannelTestConfig(on_demand=True)) with caplog.at_level("WARNING"): s.initialize(object()) - assert registered == [] # 不注册 + assert registered == [("probe_all", "9:35")] # 改锚固定盘中时刻 assert any("非交易时段" in r.message for r in caplog.records)