fix: 北交所股票处理差异,异常 (#1234) - #1235
Conversation
🤖 自动审查报告
📁 修改的文件
🧠 AI 代码审查意见结论: Ready to Merge 审查结果:
详细审查意见:
总结:
|
There was a problem hiding this comment.
Pull request overview
本 PR 以最小改动补齐北交所(BSE)股票代码在系统各入口的兼容性:统一支持 BJ 前缀与 .BJ 后缀的识别/校验,使 Web 自动补全提交与后端 Analysis API 校验路径一致,并确保 Tushare ts_code 生成能保留/推导 .BJ。
Changes:
- 后端:在共享股票代码工具中加入
.BJ/BJ的 code-like 识别与归一化支持,用于 Analysis API 输入边界判断。 - 前端:补充 StockAutocomplete 测试,覆盖北交所建议项按 canonical
.BJ形式提交。 - 测试与文档:新增/扩展多处测试用例与用户文档/Changelog,明确北交所代码格式与支持的前后缀形式。
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| apps/dsa-web/src/components/StockAutocomplete/tests/StockAutocomplete.test.tsx | 增加北交所建议项的提交行为测试,确保提交 canonical .BJ code。 |
| docs/CHANGELOG.md | 在 [Unreleased] 末尾追加北交所 BJ 前后缀校验修复记录。 |
| docs/full-guide.md | 更新“支持的股票代码格式”表格,补充 BJ 前缀/.BJ 后缀说明与示例。 |
| docs/full-guide_EN.md | 同步英文指南中的北交所代码格式说明与示例。 |
| docs/openclaw-skill-integration.md | 更新 openclaw Skill 集成文档中的北交所代码格式说明与示例。 |
| src/services/stock_code_utils.py | 在 code-like 识别/归一化工具中加入 .BJ/BJ 支持。 |
| tests/test_analysis_api_contract.py | 增加 Analysis API 合约测试:autocomplete 来源的 920493.BJ 不再触发 name resolver 且可入队。 |
| tests/test_name_to_code_resolver.py | 扩展 resolver 的 code-like/normalize 边界测试,覆盖 BJ920493/920493.BJ。 |
| tests/test_stock_code_bse.py | 扩展 TushareFetcher 北交所 exchange hint 输入的保留/转换测试。 |
| tests/test_stock_code_utils.py | 扩展 stock_code_utils 的 is_code_like/normalize_code 测试,覆盖 .BJ 与 BJ。 |
| @@ -69,7 +71,7 @@ def normalize_code(raw: str) -> Optional[str]: | |||
| Supports: | |||
| - Plain digit codes: 600519, 00700 | |||
| - Suffix format: 600519.SH, 600519.SZ, 00700.HK | |||
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7d0c93dae5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ".SH": (6,), | ||
| ".SZ": (6,), | ||
| ".SS": (6,), | ||
| ".BJ": (6,), |
There was a problem hiding this comment.
Reject non-BSE codes with BJ exchange hints
When a user submits a non-BSE six-digit code with a BJ hint, e.g. 600519.BJ (or BJ600519 via the new prefix entry), this length-only rule makes is_code_like accept it and the analysis API bypasses name resolution; downstream TushareFetcher._convert_stock_code preserves any dotted suffix unchanged, so the request is sent as the invalid 600519.BJ instead of being rejected or treated as Shanghai. The repo already defines BSE ranges in is_bse_code, so the BJ prefix/suffix path should validate those ranges rather than accepting any 6 digits.
Useful? React with 👍 / 👎.
ZhuLinsen
left a comment
There was a problem hiding this comment.
评审结论
- 必要性:通过,修复北交所
BJ前缀/.BJ后缀在 API 校验、前端自动补全提交与 Tusharets_code路径中的一致性问题,符合 Issue #1234 的目标。 - 是否有对应 issue:有,Closes #1234。
- PR 类型:fix,改动集中在股票代码识别/归一化与相关回归测试、文档同步。
- description 完整性:完整,已包含动机、范围、Issue、验证命令与结果、兼容性风险、文档落点和回滚方案,符合 AGENTS.md 对 fix 类 PR 的说明要求。
- 是否可直接合入:可;当前 CI 全部成功,改动已同步
docs/CHANGELOG.md与中英文相关文档,且新增测试覆盖 API、resolver、工具函数、Tushare 转换与前端提交路径。mergeable_state=blocked在当前事实下不等同于代码不可合入,更像分支保护/权限状态。
🤖 此回复由 OpenReview Bot 自动生成,仅供参考。如有疑问请 @维护者。
6a73fc9 to
ac76234
Compare
ZhuLinsen
left a comment
There was a problem hiding this comment.
评审结论
- 必要性:通过,修复北交所
BJ前缀/.BJ后缀在 API 校验、前端提交与 Tusharets_code路径中的不一致,属于真实用户路径问题。 - 是否有对应 issue:有,Closes #1234。
- PR 类型:fix,改动集中在股票代码识别/归一化、API 契约回归、前端提交测试和对应文档同步。
- description 完整性:完整,已覆盖动机、范围、Issue、验证命令与结果、兼容性风险、文档落点和 revert 级回滚方案,符合 AGENTS.md 对 fix 类 PR 的交付要求。
- 是否可直接合入:可,当前 CI 全部成功;
mergeable_state=blocked更像分支保护/权限状态,不构成代码层阻断。
🤖 此回复由 OpenReview Bot 自动生成,仅供参考。如有疑问请 @维护者。
* fix(issue-1234): [bug]-北交所股票处理差异,异常
* fix(issue-1234): [bug]-北交所股票处理差异,异常
* fix(issue-1234): [bug]-北交所股票处理差异,异常
PR Type
Background And Problem
+182 / -9。Scope Of Change
apps/dsa-web/src/components/StockAutocomplete/__tests__/StockAutocomplete.test.tsxdocs/CHANGELOG.mddocs/full-guide.mddocs/full-guide_EN.mddocs/openclaw-skill-integration.mdsrc/services/stock_code_utils.pytests/test_analysis_api_contract.pytests/test_name_to_code_resolver.pytests/test_stock_code_bse.pytests/test_stock_code_utils.pyDocumentation And Changelog
docs/CHANGELOG.md,docs/full-guide.md,docs/full-guide_EN.md,docs/openclaw-skill-integration.md。Issue Link
Closes #1234
Verification Commands And Results
关键输出/结论 / Key output & conclusion:
Compatibility And Risk
apps/dsa-web/src/components/StockAutocomplete/__tests__/StockAutocomplete.test.tsx,docs/CHANGELOG.md,docs/full-guide.md,docs/full-guide_EN.md,docs/openclaw-skill-integration.md,src/services/stock_code_utils.py,建议按文件范围复核。Rollback Plan
git revert <merge-commit>回滚本 PR 提交,重点确认apps/dsa-web/src/components/StockAutocomplete/__tests__/StockAutocomplete.test.tsx,docs/CHANGELOG.md,docs/full-guide.md,docs/full-guide_EN.md恢复正常。Acceptance Criteria
Checklist
docs/CHANGELOG.md,并在 PR 描述中说明文档落点 / Relevant docs anddocs/CHANGELOG.mdare updated, and the documentation location is stated in this PR