From 5b75adea85cccedb0a79f892992c34b60b4c848c Mon Sep 17 00:00:00 2001 From: Codex Date: Tue, 3 Nov 2026 04:15:29 +0000 Subject: [PATCH] =?UTF-8?q?=E6=98=BE=E5=BC=8F=E5=8F=96=E7=94=A8=E4=BA=BA?= =?UTF-8?q?=E5=B7=A5=E5=80=99=E9=80=89=E5=B9=B6=E9=9A=94=E7=A6=BB=E6=97=A7?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E6=96=B9=EF=BC=88934d46f=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- UPSTREAM_PLAN_API.md | 2 ++ app/services/plan_feed.py | 3 ++- scripts/run_tests.py | 2 +- scripts/test_batch43_units.py | 2 +- scripts/test_batch54_units.py | 7 +++++++ scripts/test_batch7_units.py | 6 +++--- 6 files changed, 16 insertions(+), 6 deletions(-) diff --git a/UPSTREAM_PLAN_API.md b/UPSTREAM_PLAN_API.md index 22ec83a..57eb8c1 100644 --- a/UPSTREAM_PLAN_API.md +++ b/UPSTREAM_PLAN_API.md @@ -710,4 +710,6 @@ PMS 对应路径统一为 `/api/plan/user-candidates`,沿用交易员登录权 完整计划顶层 `user_candidates` 保存本版采用的登记;对应行带 `user_candidate` 和 `user_required`。后者表示候选需要人工来源才能成立。移除、到期及重新登记但尚未发布时,最新计划和逐票核验的 `pending_codes` 阻止旧来源继续被采纳。来源信息进入 PMS 依据指纹、提议与评审材料,既有版本核验和跨日复核继续生效。 +新版PMS读取 `/plan` 和 `/plan/check` 时显式发送 `include_user_candidates=1`。未声明支持的调用方只获得系统来源:在前列数量及主题裁剪前剔除仅依靠人工来源的行,缓存也按此选项分开;逐票核验不返回人工专属候选。未升级的PMS和其他既有调用方不会自动吸收新增来源。归档完整版本保留,普通请求的来源过滤不重写历史。 + 人工来源只接入自主建仓候选链。资金投放命令不会额外吸收仅靠人工来源新增的股票;已有系统来源仍正常参与。盘中加入的合格基础候选可补读已有技术面数据,并进入现有盘中扫描关注范围,不自行生成技术面或择时结论。到期或移除不改变已经建立的持仓管理规则。 diff --git a/app/services/plan_feed.py b/app/services/plan_feed.py index 046eb03..c47537b 100644 --- a/app/services/plan_feed.py +++ b/app/services/plan_feed.py @@ -788,6 +788,7 @@ def fetch(*, date=None, base=None, path=None, timeout=None, extra_params=None) - url = base + path to = int(timeout or 10) q = dict(extra_params or {}) + q['include_user_candidates'] = 1 # 新版 PMS 明确支持人工来源及其失效核验。 if date: q["date"] = date # date 是我们自己的语义, 不许被 extra 覆盖 try: @@ -923,7 +924,7 @@ def read_current_plan(*, code=None): import requests try: r = requests.get(p['base'].rstrip('/') + '/' + p['path'].strip('/') + '/check', - params={'code': code}, timeout=(1, min(3, max(1, p['timeout'])))) + params={'code': code, 'include_user_candidates': 1}, timeout=(1, min(3, max(1, p['timeout'])))) r.raise_for_status() payload = r.json() if (not isinstance(payload, dict) or normalize_code(payload.get('check_code')) != code diff --git a/scripts/run_tests.py b/scripts/run_tests.py index cfb8521..a6d3cc7 100644 --- a/scripts/run_tests.py +++ b/scripts/run_tests.py @@ -4,7 +4,7 @@ ====================================== 运行: docker compose run --rm pms-web python scripts/run_tests.py - test_batch54_units.py 用户候选来源、到期核验、权限与技术面补读 (8例) + test_batch54_units.py 用户候选来源、到期核验、权限、显式取用与技术面补读 (9例) 包含 (例数按 2026-10-26 隔离回归实跑校正): test_sim_reset_units.py 双账本重置、空仓证据、配置与去重保留、幂等及SQL回滚 (9例) diff --git a/scripts/test_batch43_units.py b/scripts/test_batch43_units.py index 8470190..c4f8a2d 100644 --- a/scripts/test_batch43_units.py +++ b/scripts/test_batch43_units.py @@ -54,7 +54,7 @@ class AcceptancePathTest(unittest.TestCase): 'main':[{'code':'SZ300693','name':'盛弘股份','score':230,'tier':'强传导','rank':555, 'verdict':'候选','risk':[],'company_review_text':'研究依据'}],'observe':[]} def response(url,**kw): - self.assertEqual(url,'http://bridge/plan/check');self.assertEqual(kw['params'],{'code':CODE}) + self.assertEqual(url,'http://bridge/plan/check');self.assertEqual(kw['params'],{'code':CODE,'include_user_candidates':1}) return SimpleNamespace(raise_for_status=lambda:None,json=lambda:copy.deepcopy(self.raw)) self.http=use('requests.get',side_effect=response) selected=pf.candidates(record=False,recheck_code=CODE,plan_override=pf.parse_plan(self.raw),route_by_verdict=True) diff --git a/scripts/test_batch54_units.py b/scripts/test_batch54_units.py index f21bd0b..f509d32 100644 --- a/scripts/test_batch54_units.py +++ b/scripts/test_batch54_units.py @@ -57,6 +57,13 @@ class UserCandidateTests(unittest.TestCase): self.assertNotIn(CODE,[r['ts_code'] for r in rows]) self.assertEqual(len(plan['main']),2) + def test_plan_request_explicitly_declares_user_source_support(self): + import requests + response=Mock();response.json.return_value=payload() + with patch.object(requests,'get',return_value=response) as get: + pf.fetch(base='http://plan.test',path='/plan',timeout=3) + self.assertEqual(get.call_args.kwargs['params']['include_user_candidates'],1) + def test_proxy_secret_actor_failure_and_redirect(self): import requests from app.services import param_store diff --git a/scripts/test_batch7_units.py b/scripts/test_batch7_units.py index 6424fd1..a9aa8a5 100644 --- a/scripts/test_batch7_units.py +++ b/scripts/test_batch7_units.py @@ -316,7 +316,7 @@ def _(): finally: restore() # date 是 PMS 自己的语义, extra 里同名键不许赢 - assert calls[0]["params"] == {"limit": "1000", "date": "2026-07-29"}, calls[0]["params"] + assert calls[0]["params"] == {"limit": "1000", "date": "2026-07-29", "include_user_candidates": 1}, calls[0]["params"] # ================================================================ 新鲜度 @@ -623,7 +623,7 @@ def _(): finally: restore() assert calls[0]["url"] == "http://192.168.16.155:8300/plan", calls - assert calls[0]["params"] == {"date": "2026-07-29"} and calls[0]["timeout"] == 7 + assert calls[0]["params"] == {"date": "2026-07-29", "include_user_candidates": 1} and calls[0]["timeout"] == 7 assert p["date"] == "2026-07-29" and p["requested_date"] == "2026-07-29" assert p["url"].endswith("/plan") and p["fetched_at"] > 0 # 不传 date 时不能带一个 date=None 的空参上去 @@ -632,7 +632,7 @@ def _(): pf.fetch(base="http://x:8300", path="/plan", timeout=3) finally: restore2() - assert calls2[0]["params"] is None, calls2 + assert calls2[0]["params"] == {"include_user_candidates": 1}, calls2 @case("取数·HTTP 报错/JSON 坏掉一律包装成 PlanFeedError, 消息给人看、接口地址进日志")