收敛广域无方向记录的账本写入

This commit is contained in:
baobao 2026-11-11 16:05:59 +08:00
parent 9dbdd84c41
commit ce91a354cb
3 changed files with 19 additions and 1 deletions

View File

@ -30,8 +30,16 @@ def refresh(*, now=None, dry_run=False):
states = data.get('states')
if not isinstance(states, list) or len(states)>6000:
raise ValueError('合成择时响应超过完整读取边界')
# 广域v3f覆盖上千只票。缺少第二组的无方向记录不进入PMS账本;
# 已有方向必须接收WAIT,及时撤销过期或冲突的旧结论。
known_rows = rotation_repo.recent(timing_state.KIND, 6001)
if len(known_rows) >= 6001:
raise ValueError('本地方向状态超过完整读取上限')
known = {r['id'] for r in known_rows}
out = {'enabled': True, 'accepted': 0, 'invalid': 0, 'source_errors': data.get('errors', []), 'actions': []}
for state in states:
if state.get('action') == 'WAIT' and timing_state.key(state.get('ts_code', '')) not in known:
continue
event = contract.valid(state, now, since=param_store.get('PMS_TIMING_FUSION_START_AT', ''))
if not event:
out['invalid'] += 1

View File

@ -202,7 +202,7 @@ HERE = os.path.dirname(os.path.abspath(__file__))
ROOT = os.path.dirname(HERE)
# 退出纪律专项:两次独立清仓信号、评级下降、事务、双策略隔离及撤单收尾。
SUITES = [
"test_timing_fusion.py", # 三组证据契约、二次清仓与恢复(13例)
"test_timing_fusion.py", # 三组证据契约、二次清仓与恢复(14例)
"test_signal_recovery.py", # 最新方向、停买恢复、网格合议、关注入口与负净成本(16例)
"test_grid_execution.py",
"test_broad_funds.py", "test_etf_observation.py", "test_risk_exit.py", "test_rotation_accounting_units.py", "test_cost_precision.py", "test_execution_basis_decimal.py",

View File

@ -102,6 +102,16 @@ class ServiceTests(recovery.DirectionTests):
self.assertEqual(self.state()['count'],1)
self.assertEqual(timing_state.latest(base.CODE,now)['key'],a['key'])
def test_broad_missing_states_do_not_write_unrelated_ledger(self):
from types import SimpleNamespace
now=self.setup_fusion();a=fused('WAIT',at=now)
response=SimpleNamespace(raise_for_status=lambda:None,json=lambda:{'version':contract.VERSION,'enabled':True,'states':[a]})
with patch('requests.get',return_value=response):
self.assertEqual(timing_fusion.refresh(now=now)['accepted'],0)
self.save(fused('BUY',at=now))
self.assertEqual(timing_fusion.refresh(now=now)['accepted'],1)
self.assertEqual(timing_state.latest(base.CODE,now)['action'],'WAIT')
def test_fusion_manual_halt_not_recovered(self):
now=self.setup_fusion();a=fused(at=now);self.save(a);risk_exit.on_signal(a,now=now)
self.params['PMS_GLOBAL_BUY_HALT']=True