Skip to content

Add domestic futures analysis support - #1228

Closed
DesayGo wants to merge 1 commit into
ZhuLinsen:mainfrom
DesayGo:Futures_Stock_Analysis
Closed

Add domestic futures analysis support#1228
DesayGo wants to merge 1 commit into
ZhuLinsen:mainfrom
DesayGo:Futures_Stock_Analysis

Conversation

@DesayGo

@DesayGo DesayGo commented May 8, 2026

Copy link
Copy Markdown

PR Type

  • fix
  • feat
  • refactor
  • docs
  • chore
  • test

Background And Problem

请描述当前问题、影响范围与触发场景。
(EN) Describe the problem, its impact, and what triggers it.

Scope Of Change

请列出本 PR 修改的模块和文件范围。
(EN) List the modules and files changed in this PR.

Issue Link

必须填写以下之一 / Fill in one of:

  • Fixes #<issue_number>
  • Refs #<issue_number>
  • 无 Issue 时说明原因与验收标准 / If no issue, explain the motivation and acceptance criteria

Verification Commands And Results

请填写你实际执行过的命令和关键结果(不要只写"已测试")。
(EN) Paste the commands you actually ran and their key output (don't just write "tested"):

# example
./scripts/ci_gate.sh
python -m pytest -m "not network"

关键输出/结论 / Key output & conclusion:

Compatibility And Risk

请说明兼容性影响、潜在风险(如无请写 None)。
(EN) Describe compatibility impact and potential risks (write None if not applicable).

  • 若本 PR 修改第三方模型 / API 的兼容语义、请求参数、路由前缀或 provider fallback,请提供官方来源链接或公告,并说明这是长期约束、当前运行时约束还是临时兼容处理。
    (EN) If this PR changes third-party model/API compatibility, request parameters, routing prefixes, or provider fallback behavior, include an official source link or announcement and clarify whether the rule is permanent, runtime-specific, or a temporary compatibility workaround.)
  • 若本 PR 依赖特定运行时 / 锁定依赖窗口(例如 LiteLLM 版本范围、OpenAI-compatible 路由、YAML alias 行为),请写明当前验证过的兼容范围与覆盖路径。
    (EN) If this PR depends on a specific runtime or pinned dependency window (for example a LiteLLM version range, OpenAI-compatible routing, or YAML alias behavior), state the compatibility window you verified and which code paths were covered.)
  • 若本 PR 触及运行时配置保存、清理、迁移或回填逻辑,请明确说明旧配置是否会被自动改写、清空、迁移或保持不变,以及用户如何恢复原行为。
    (EN) If this PR touches runtime config save/cleanup/migration/backfill logic, explicitly describe whether existing config is rewritten, cleared, migrated, or left intact, and how users can restore the previous behavior.)

Rollback Plan

请至少写一句可执行的回滚方案(必填)。
(EN) Provide at least one actionable rollback step (required).

  • 如果是兼容性修复,默认应写出最小回滚方式(例如 revert this PR),并说明是否需要额外回滚配置或数据迁移。
    (EN) For compatibility fixes, include the minimal rollback path (for example revert this PR) and whether any additional config or data rollback is required.)

EXTRACT_PROMPT Change (if applicable)

若本 PR 修改了 src/services/image_stock_extractor.py 中的 EXTRACT_PROMPT,请在此处粘贴完整变更后的 prompt。
If this PR changes EXTRACT_PROMPT in src/services/image_stock_extractor.py, paste the full updated prompt here:

展开 / Expand: Full EXTRACT_PROMPT
(paste full prompt here)

Checklist

  • 本 PR 有明确动机和业务价值 / This PR has a clear motivation and value
  • 已提供可复现的验证命令与结果 / Reproducible verification commands and results are included
  • 已评估兼容性与风险 / Compatibility and risk have been assessed
  • 已提供回滚方案 / A rollback plan is provided
  • 若涉及用户可见变更,已同步更新相关文档与 docs/CHANGELOG.mdREADME.md 仅在首页级信息变化时更新,细节优先写入 docs/*.md / If user-visible changes are included, relevant docs and docs/CHANGELOG.md are updated; README.md is updated only for homepage-level changes, with details kept in docs/*.md

@DesayGo
DesayGo requested a review from ZhuLinsen as a code owner May 8, 2026 08:41
@github-actions github-actions Bot added ai data-source documentation Improvements or additions to documentation size/XL testing labels May 8, 2026
@DesayGo DesayGo closed this May 8, 2026
@github-actions

github-actions Bot commented May 8, 2026

Copy link
Copy Markdown

🤖 自动审查报告

项目 结果
📊 变更文件 30 个
➕ 新增行数 705 行
➖ 删除行数 35 行
🔍 静态检查 ✅ 通过
🧠 AI 审查 ✅ 已完成

📁 修改的文件

  • 📝 .env.example (+6/-0)
  • 📝 api/app.py (+16/-3)
  • 📝 api/v1/endpoints/analysis.py (+21/-4)
  • 📝 api/v1/endpoints/stocks.py (+20/-0)
  • 📝 api/v1/schemas/analysis.py (+11/-0)
  • 📝 api/v1/schemas/stocks.py (+20/-0)
  • 📝 apps/dsa-web/src/api/analysis.ts (+2/-0)
  • 📝 apps/dsa-web/src/api/stocks.ts (+10/-0)
  • 📝 apps/dsa-web/src/components/StockAutocomplete/StockAutocomplete.tsx (+16/-5)
  • 📝 apps/dsa-web/src/components/StockAutocomplete/SuggestionsList.tsx (+1/-0)
  • 📝 apps/dsa-web/src/components/StockAutocomplete/__tests__/StockAutocomplete.test.tsx (+51/-1)
  • 📝 apps/dsa-web/src/components/report/ReportStrategy.tsx (+6/-4)
  • 📝 apps/dsa-web/src/components/report/ReportSummary.tsx (+1/-1)
  • 🆕 apps/dsa-web/src/components/report/__tests__/ReportStrategy.test.tsx (+25/-0)
  • 🆕 apps/dsa-web/src/hooks/__tests__/useFuturesIndex.test.ts (+48/-0)
  • 🆕 apps/dsa-web/src/hooks/useFuturesIndex.ts (+80/-0)
  • 📝 apps/dsa-web/src/hooks/useHomeDashboardState.ts (+2/-0)
  • 📝 apps/dsa-web/src/pages/HomePage.tsx (+31/-2)
  • 📝 apps/dsa-web/src/pages/__tests__/HomePage.test.tsx (+32/-0)
  • 📝 apps/dsa-web/src/stores/stockPoolStore.ts (+20/-5)

... 还有 10 个文件


🧠 AI 代码审查意见

审查结论

Not Ready

结构化审查结果

必要性

  • 通过
  • 理由: PR 标题“Add domestic futures analysis support”表明这是一项新增国内期货分析支持的功能,具有明确的业务价值,扩展了平台的资产覆盖范围。

关联性

  • 不通过
  • 证据: PR 描述中的 "Issue Link" 字段为空,且未说明无 Issue 的原因或验收标准。这不符合“必须填写以下之一”的要求。

类型

  • 建议类型: feat (功能新增)

描述完整性

  • 不完整
  • 缺失项:
    • PR Type: 未勾选。
    • Background And Problem: 未填写。
    • Scope Of Change: 已提供文件列表,但未提供自然语言描述。
    • Issue Link: 未填写。
    • Verification Commands And Results: 未填写实际执行的命令和关键结果。特别是,对于 Python 后端改动,未提及 ./scripts/ci_gate.sh 的执行情况。
    • Compatibility And Risk: 未填写。
    • Rollback Plan: 未填写。
    • Checklist: 未勾选。

风险级别

  • 关键风险:
    • 缺乏文档与验证信息: PR 描述中缺失关键的背景、问题、兼容性、风险评估和验证结果,导致无法全面评估潜在的运行时问题、数据准确性或与现有系统的集成风险。
    • 新数据源/业务逻辑引入: 新增期货分析支持涉及数据获取、数据清洗、分析逻辑、前端交互等多个环节,每个环节都可能引入新的风险点,例如数据源稳定性、数据格式兼容性、分析模型对期货数据的适配性等。由于缺乏验证结果,这些风险无法得到有效评估。
    • 前端 MIME 类型修复: api/app.py 中对前端 JS 模块的 MIME 类型修复虽然是积极的改动,但也需确保不会对其他静态资源类型造成回归。

必改项 (Blocking Items)

  1. 完善“Rollback Plan”: PR 描述中“Rollback Plan”字段为空。根据仓库 AGENTS.md 规则,必须提供至少一句可执行的回滚方案。这是阻断项。
  2. 完善“Issue Link”: PR 描述中“Issue Link”字段为空。必须关联 Issue 或说明无 Issue 的原因与验收标准。
  3. 完善“Verification Commands And Results”: 必须提供你实际执行过的命令和关键结果,以证明变更已充分测试。这对于确保新功能的稳定性和正确性至关重要。
  4. 完善“Compatibility And Risk”: 必须描述兼容性影响和潜在风险。新功能引入可能影响现有系统,需要明确评估。
  5. 勾选“Checklist”: 确保所有适用的清单项都已检查,以表明已完成必要的考虑和工作。

建议项 (Suggestions)

  1. 填写“PR Type”: 请勾选正确的 PR 类型,根据内容应为 feat
  2. 填写“Background And Problem”: 简要描述增加国内期货分析支持的背景和解决的用户痛点,这将有助于审阅者和未来的维护者理解该功能的价值。
  3. 补充“Scope Of Change”描述: 尽管已提供了文件列表,但用自然语言概括修改的模块和文件范围,能让审阅者更快地掌握 PR 的整体影响。
  4. 在“Verification Commands And Results”中提及 ./scripts/ci_gate.sh 执行情况: 对于 Python 后端改动,如果已执行该脚本,请在验证结果中说明;如果因特定原因跳过,也请说明。
  5. 代码可读性与一致性:
    • api/app.py_missing_asset_media_type_asset_media_type 函数,对于 application/javascript 特殊处理为 text/javascript,这解决了特定浏览器兼容性问题,但建议在注释中更详细地说明其必要性(例如针对 Safari/older Chrome 的模块加载问题)。
    • 由于 diff 过长已截断,无法对所有修改文件进行详细的代码风格和逻辑审查。请确保所有新增或修改的 Python 和 TypeScript 文件遵循仓库的编码规范,并有足够的内联注释解释复杂逻辑。

基于上述阻断项,此 PR 无法合入。请在完善必要信息后重新提交审查。


💡 提示: 请确保代码已通过本地测试,并遵循项目代码规范。

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 29ec2ae4d4

ℹ️ 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".

void submitAnalysis({
stockCode: selectedReport.meta.stockCode,
stockName: selectedReport.meta.stockName,
assetType: selectedReport.meta.assetType ?? 'stock',

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve futures asset type when re-running history reports

handleReanalyze falls back to 'stock' when selectedReport.meta.assetType is absent, but history payloads still omit that field (the history schema/mapper only expose stock metadata). As a result, re-running a futures report is submitted through the stock path, which either fails validation for contract-like codes (e.g. JM2609) or can analyze the wrong instrument (e.g. RB as a US ticker). This breaks the new futures workflow for any report reopened from history.

Useful? React with 👍 / 👎.

Comment thread main.py
Comment on lines +963 to +966
if futures_codes is not None:
run_full_analysis(config, args, futures_codes, asset_type="futures")
else:
run_full_analysis(config, args, stock_codes)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Route scheduled runs through futures mode when --futures is set

The new --futures argument is only honored in the immediate-run branch, while schedule mode still invokes run_full_analysis without asset_type="futures". In practice, python main.py --schedule --futures ... will continue to run stock analysis semantics and ignore the futures mode path, so the CLI behavior is inconsistent between one-off and scheduled execution.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai data-source documentation Improvements or additions to documentation size/XL testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant