Skip to content

fix: 提升分析报告数据质量 — 修复PB/PE错误、消除LLM数据编造#734

Open
xiaodutou wants to merge 14 commits into
hsliuping:mainfrom
xiaodutou:main
Open

fix: 提升分析报告数据质量 — 修复PB/PE错误、消除LLM数据编造#734
xiaodutou wants to merge 14 commits into
hsliuping:mainfrom
xiaodutou:main

Conversation

@xiaodutou

Copy link
Copy Markdown

Summary

  • PB/PE 价格修复:MongoDB 不可用时从 app cache 获取真实股价,修复 PB=0.42x(应为 3.46x)的严重误判
  • 价格提取兜底:兼容 "最新价格:" 格式,不再因数据格式差异使用 10.0 默认值
  • 净利润单位修复:智能判断 AKShare 返回值单位(元 vs 万元),修复 61,054.53 亿元错误
  • 全链路事实约束:9 个 agent prompt 注入反编造约束,杜绝 LLM 伪造财务数据/未来事件
  • 前端空代码防护:Detail.vue、Favorites、Screening 增加空股票代码守卫

验证结果(第二次完整分析)

数据项 修复前 修复后 真实值
PB 0.42x(严重破净误判) 3.46x 3.46x
PE 23.3x 190.8x 190.8x
净利润引用 61,054.53亿元 7.54亿元 7.54亿
未来事件编造

Test plan

  • 运行 601127 分析,验证 fundamentals_report 中 PB=3.46x
  • 验证辩论报告中净利润引用均为 7.54亿元
  • 验证无 "即将上市"、"将突破" 等未来事件编造
  • 前端空股票代码守卫触发正常

Generated with Claude Code

xiaodutou and others added 14 commits May 5, 2026 14:14
- 新增 TUSHARE_USE_CUSTOM_API / TUSHARE_API_URL 环境变量配置
- 新增 _custom_api_call() 方法,通过 HTTP POST 调用自定义 Tushare API
- 所有数据接口(实时行情、历史K线、基本面等)优先走自定义API,不可用时降级到官方API
- 清理代码中多余控制字符和冗余注释

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
feat: 添加 Tushare 自定义 API 支持,支持自定义 API 端点调用与自动降级
- 测试连接时优先检查 TUSHARE_USE_CUSTOM_API 环境变量
- 配置了自定义 API 时,测试请求走自定义端点而非官方 tushare.pro
- 未配置自定义 API 时保持原有的官方 API 测试逻辑

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
fix: Tushare 测试连接支持自定义 API
…bug; add data quality gates for analysis pipeline

- Fix tushare_adapter.py: _normalize_symbol → _normalize_ts_code, causing
  K-line API to return empty data for all A-share stocks (e.g. 601127)
- Add data quality checks (data_quality.py) to terminate analysis when all
  data sources fail, preventing hangs in fundamentals/market/news analysts
- Update conditional_logic.py, agent_states.py, research_manager.py to
  support data_all_failed flag for early termination
- Remove dead custom API code paths from tushare_adapter.py

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…bug; add data quality gates for analysis pipeline

- Fix tushare_adapter.py: _normalize_symbol → _normalize_ts_code, causing
  K-line API to return empty data for all A-share stocks (e.g. 601127)
- Add data quality checks (data_quality.py) to terminate analysis when all
  data sources fail, preventing hangs in fundamentals/market/news analysts
- Update conditional_logic.py, agent_states.py, research_manager.py to
  support data_all_failed flag for early termination
- Remove dead custom API code paths from tushare_adapter.py

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
fix: K-line chart display + data quality gates for analysis pipeline
核心修复:
1. PB/PE 价格修复:当 MongoDB 不可用时,价格从默认值 10.0 降级为从 app cache
   (market_quotes) 获取真实股价,修复 PB=0.42x(应为 3.46x)的严重误判
2. 价格提取修复:_generate_fundamentals_report 增加对 "最新价格:" 格式的兜底提取,
   兼容 get_china_stock_data_unified 返回的数据格式
3. 净利润单位修复:_extract_quarterly_financials 智能判断 AKShare 返回值的单位
   (元 vs 万元),修复 61,054.53 亿元的单位转换错误
4. 全链路事实约束:在 9 个 agent(Fundamentals Analyst、Bull/Bear Researcher、
   Research Manager、3 Debaters、Risk Manager、Trader)的 prompt 中注入 6 点
   反编造事实约束,杜绝 LLM 编造财务数据、未来事件等
5. 前端空代码防护:Detail.vue、Favorites、Screening 增加空股票代码守卫,
   消除 "股票代码不能为空" 错误提示

验证结果(第二次分析):
- PB: 0.42x → 3.46x ✅
- PE: 23.3x → 190.8x ✅
- 净利润引用: 全部为正确的 7.54亿元 ✅
- 无编造未来事件 ✅

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
fix: 提升分析报告数据完整性与质量
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant