diff --git a/app/services/proposal_service.py b/app/services/proposal_service.py index 27cb478..479f15d 100644 --- a/app/services/proposal_service.py +++ b/app/services/proposal_service.py @@ -213,12 +213,14 @@ def scan_and_route(*, now=None, dry_run: bool = False, review_instruction=None, # ---- 新建仓: 候选池那一路 (取不到候选池不影响上面四类, 反之亦然) ---- open_cands = [] + review_source = (((review_instruction or {}).get('progress') or {}).get('plan') or {}).get('candidate_source') if open_autonomy == AUTONOMY_OFF: out["skipped"].append({"action": ae.A_OPEN, "why": "新建仓档位 off, 不扫描候选池"}) else: try: open_cands = _scan_open(view, params, stock_params, skip, mkt, out, now=now, record_consumption=not dry_run, + **({'candidate_source': 'dividend'} if review_source == 'dividend' else {}), **({'review_instruction': review_instruction} if review_instruction else {})) except Exception as e: logger.exception("新建仓扫描失败") @@ -256,6 +258,9 @@ def scan_and_route(*, now=None, dry_run: bool = False, review_instruction=None, if result: result['candidate']['qty'] = min(int(result['candidate']['qty']), remaining) result['candidate']['hard_numbers']['qty'] = result['candidate']['qty'] + if review_source == 'dividend': + # 原人工选定的独立来源不得因跨日复核升级为自主选股。 + result.update(auto_exec=False, force_queue=True) return {**out, 'review': result} for group_index, group in enumerate((list(scanned['candidates']), open_cands)): @@ -433,13 +438,14 @@ def _scan_open(view, params, stock_params, skip, mkt, out, now=None, # 名额与金额都要扣掉**在途的建仓承诺** (2026-08-28 审查修): names_count 只数已成交 # 持仓, 在途 OPEN 指令与等拍板的 OPEN 提议两头都不占 —— 候选没进买入区间时指令滞留 # 在途, 下一跳名额照旧又放两只, 几分钟就把持仓数上限击穿。同票去重挡不住换一只票。 - if candidate_source == 'dividend': + if review_instruction: + inflight = _inflight_open_commitments(view, exclude_proposal=exclude_proposal, + exclude_instruction=review_instruction['instruction_id'], strict=True) + elif candidate_source == 'dividend': inflight = _inflight_open_commitments(view, exclude_proposal=exclude_proposal, strict=True) cands = [c for c in cands if c['ts_code'] not in inflight['names']] else: - inflight = (_inflight_open_commitments(view, exclude_proposal=exclude_proposal, - exclude_instruction=review_instruction['instruction_id'], strict=True) - if review_instruction else _inflight_open_commitments(view, exclude_proposal=exclude_proposal)) + inflight = _inflight_open_commitments(view, exclude_proposal=exclude_proposal) slots = int(p["max_names"] or 0) - int(t["names_count"] or 0) - len(inflight["names"]) room = float(p["portfolio_cap"] or 0) * float(p["scale"] or 0) \ - float(t["portfolio_mv"] or 0) - inflight["amount"] diff --git a/docs/跨日买入决策复核_2026-10-30.md b/docs/跨日买入决策复核_2026-10-30.md index f52a077..97232cf 100644 --- a/docs/跨日买入决策复核_2026-10-30.md +++ b/docs/跨日买入决策复核_2026-10-30.md @@ -24,6 +24,6 @@ ## 验证与发布记录 -开发机增加32项专项测试,包括真实SQLite单表事务回滚、撤单未终态、迟到成交、数量预留、用户撤销并发、人工确认与完整选股接线。全量断网回归及页面三道护栏经隔离入口执行。页面1440及390宽浏览器重放验证复核状态、实际委托限价、标签切换和撤单弹窗关闭,写请求为0;属于开发机复现,不是交易员实际登录验收。 +开发机增加33项专项测试,包括真实SQLite单表事务回滚、撤单未终态、迟到成交、数量预留、用户撤销并发、人工确认与完整选股接线。全量断网回归及页面三道护栏经隔离入口执行。页面1440及390宽浏览器重放验证复核状态、实际委托限价、标签切换和撤单弹窗关闭,写请求为0;属于开发机复现,不是交易员实际登录验收。 发布、155当日自然复核及QMT恢复证据在完成后追加。未用真实测试委托制造通过。 diff --git a/scripts/run_tests.py b/scripts/run_tests.py index b81989e..5c25caf 100644 --- a/scripts/run_tests.py +++ b/scripts/run_tests.py @@ -5,7 +5,7 @@ 运行: docker compose run --rm pms-web python scripts/run_tests.py 包含 (例数按 2026-10-26 隔离回归实跑校正): - test_batch51_units.py 跨日决策复核、撤单回报、数量约束、人工确认与真实SQL事务及完整选股接线 (32例) + test_batch51_units.py 跨日决策复核、撤单回报、数量约束、人工确认与真实SQL事务及完整选股接线 (33例) test_batch50_units.py QMT限价等待、价格来源故障、用户暂停、配额防重和试算隔离 (14例) test_batch49_units.py 持仓分组、同名股票与批次归属、未迁移及缺数展示 (8例) test_batch48_units.py 策略账本隔离、轮换优先级、交易单位、模拟直接启用、读数及微盘50规则换版 (55例) diff --git a/scripts/test_batch51_units.py b/scripts/test_batch51_units.py index 1564bf7..4a5876a 100644 --- a/scripts/test_batch51_units.py +++ b/scripts/test_batch51_units.py @@ -275,6 +275,15 @@ class ScanIntegrationTests(unittest.TestCase): r = self.scan() self.assertTrue(r['errors']); self.assertIsNone(r['review']) + def test_separate_manual_source_is_preserved_and_never_upgraded(self): + from app.services import dividend_feed + self.parent['progress']['plan'] = {'candidate_source': 'dividend'} + selected = self.feed.candidates(record=False) + with patch.object(dividend_feed, 'candidates', return_value=selected) as separate: + r = self.scan() + self.assertIsNotNone(r['review'], r); self.assertFalse(r['review']['auto_exec']) + self.assertTrue(separate.called) + def test_prepared_verdict_path_does_not_call_model(self): r = ps.scan_and_route(now=NOW, review_instruction=copy.deepcopy(self.parent), prepared_verdict={'verdict': 'PASS', 'reason': '今日已准备', 'degraded': False})