fix(dataflows): 修复 _get_tushare_stock_info 缺失导致 Tushare 备用数据源永久失效#703
Open
sliangliang wants to merge 1 commit into
Open
fix(dataflows): 修复 _get_tushare_stock_info 缺失导致 Tushare 备用数据源永久失效#703sliangliang wants to merge 1 commit into
sliangliang wants to merge 1 commit into
Conversation
The _try_fallback_stock_info() at line 1616 calls
self._get_tushare_stock_info(symbol) but this method was never
defined on DataSourceManager, causing AttributeError every time
Tushare is reached as a fallback source. Effect: Tushare's stock
info API is permanently unreachable in fallback path, even with
a valid TUSHARE_TOKEN configured.
Symptoms in logs:
❌ [Tushare] 获取股票信息失败:
'DataSourceManager' object has no attribute
'_get_tushare_stock_info'
This was the missing implementation referenced (and assumed
to exist) in docs/development/CIRCULAR_CALL_ANALYSIS.md and
docs/integration/data-sources/DATA_SOURCE_MANAGER_ENHANCEMENT.md.
Implementation notes:
- Calls provider.api.stock_basic() directly (sync), avoids the
interface.get_china_stock_info_tushare() function which would
call back into this method and cause infinite recursion.
- Returns the same dict shape used by _get_akshare_stock_info /
_get_baostock_stock_info for consistency.
Verified: Tushare branch now returns real stock names (e.g.
688008 → 澜起科技 / 半导体) instead of falling through to
BaoStock as the final fallback.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题描述
DataSourceManager._try_fallback_stock_info()(data_source_manager.py:1616) 调用了self._get_tushare_stock_info(symbol),但这个方法在类里从未实现,导致:影响:当默认数据源(如 AKShare)失败、降级到备用源时,Tushare 这一档永远进不去,即便用户配置了有效的
TUSHARE_TOKEN也用不上 → 总是降级到 BaoStock 兜底 → 部分公司基本信息(行业、上市日期等)不准。复现
DEFAULT_CHINA_DATA_SOURCE=akshare(默认)Connection aborted)_try_fallback_stock_info流程修复
在
_get_akshare_stock_info之前补上缺失的方法实现。关键设计:
provider.api.stock_basic()(同步接口),不调interface.get_china_stock_info_tushare()—— 因为后者会回调本方法,造成无限递归_get_akshare_stock_info/_get_baostock_stock_info保持一致{'source': 'tushare_failed'}等明确的 source 标签,便于上层识别注:原作者在
docs/development/CIRCULAR_CALL_ANALYSIS.md和docs/integration/data-sources/DATA_SOURCE_MANAGER_ENHANCEMENT.md中都提到过这个方法(且文档说"已修复循环调用 ✅"),但实际代码没有实现。验证
类型
影响范围
_try_fallback_stock_info()的 Tushare 分支