fix: stock_zh_a_disclosure_{report,relation}_cninfo#7259
Closed
qiyongsen wants to merge 1 commit into
Closed
Conversation
修正两函数共有的 `if market == "沪深京" or "基金":` 恒真条件
(因运算符优先级等价于 `if (market == "沪深京") or "基金":`,
对 market="监管"/"预披露" 等 __get_stock_json 没有 elif 的路径
会 fall through 到默认 A 股 stock list 并 silently 返错),
改为白名单 `if market in ("沪深京", "基金"):` 与原始意图对齐.
relation 函数额外修复:
- if 条件原误写 `market == "沪深京"` 且 __get_stock_json(symbol) 误用 symbol 参数
- totalAnnouncement=0 时提前返回空 DataFrame, 避免末尾按列重排引发 KeyError
- 公告时间改用 dt.tz_localize(None) 而非 dt.tz_convert(None),
返回北京时间而非 UTC (实测原代码偏差 8 小时)
88b46b4 to
e53ba98
Compare
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.
Summary
修复
stock_zh_a_disclosure_relation_cninfo三处问题, 与stock_zh_a_disclosure_report_cninfo(#7254) 行为对齐. 顺带修正两函数共有的if market == "沪深京" or "基金":语法 bug.stock_zh_a_disclosure_relation_cninfo三处修复if market == "沪深京":且__get_stock_json(symbol)误用 symbol 参数, 与 report 函数对齐改为白名单 +__get_stock_json(market). 修复market="基金"路径下stock_id_map=""引发的TypeError: string indices must be integerstotalAnnouncement=0时提前返回空 DataFrame, 避免末尾按列重排引发 KeyError (与 AKShare 接口问题报告 stock_zh_a_disclosure_report_cninfo #7251 / fix: handle empty cninfo disclosure reports #7254 同模式)dt.tz_localize(None)而非dt.tz_convert(None).tz_convert(None)会把 Asia/Shanghai 时间转回 UTC, 实测公告原始时间戳上海 16:37 在当前代码返回 08:37 (偏差 8 小时);tz_localize(None)才是丢掉时区信息保留 wall-clockstock_zh_a_disclosure_report_cninfo一处修复if market == "沪深京" or "基金":因运算符优先级实际等价于if (market == "沪深京") or "基金":, 表达式恒真. 对market="监管"/"预披露"等__get_stock_json没有 elif 的 market, 会 fall through 到默认 A 股 stock list, 将错误的 A 股 orgId 拼入请求 silently 返错. 改为白名单if market in ("沪深京", "基金"):与原始意图对齐, 不扩展未测试的 market 范围.Test
Runtime check (节选):
Related: #7251, #7254