Skip to content

修复天天基金 F10DataApi 下线导致的增量更新失败 - #209

Merged
refraction-ray merged 1 commit into
refraction-ray:masterfrom
zibin-zhao:fix-eastmoney-lsjz-api
Jul 25, 2026
Merged

refraction-ray merged 1 commit into
refraction-ray:masterfrom
zibin-zhao:fix-eastmoney-lsjz-api

Conversation

@zibin-zhao

Copy link
Copy Markdown
Contributor

问题

天天基金已下线 fund.eastmoney.com/f10/F10DataApi.aspx。该地址目前 302 跳转到
fundf10.eastmoney.com/F10DataApi.aspx,而后者返回 404:

$ curl -sIL "http://fund.eastmoney.com/f10/F10DataApi.aspx?type=lsjz&code=110020&page=1&per=1"
302 -> https://fundf10.eastmoney.com/F10DataApi.aspx?...
404

该页面是 fundinfo.update 和 mfundinfo.update 的唯一数据来源,所以只要本地存在缓存副本,
场外基金的增量更新就会抛 HttpStatusError。表现比较隐蔽:首次抓取走 pingzhongdata 一切正常,
之后每一次更新都失败,因此只有配合 set_backend 长期使用的场景才会踩到。

改动

两处 update 改用 api.fund.eastmoney.com/f10/lsjz,JSON 字段与原表格列一一对应:

原表格列 JSON 字段
净值日期 FSRQ
单位净值(货币基金为每万份收益) DWJZ
累计净值(货币基金为七日年化) LJJZ
分红送配 FHSP

分页逻辑保持不变 —— 新接口同样有每页 20 条的服务端上限(请求 pageSize=60 实际只返回 20 条),
原先每页 10 条的写法依然适用。请求需要带 fundf10.eastmoney.com 的 referer。

验证

tests/test_info.py::test_fund_update(覆盖 fundinfo 与 mfundinfo 两条增量路径):

  • 改动前:FAILED ... xalpha.exceptions.HttpStatusError
  • 改动后:1 passed

tests/test_info.py 整体从 9 passed / 2 failed 变为 10 passed / 1 failed。仍失败的 test_csvio
是卡在 indexinfo 那一步(多次运行分别报 SSLError 和 FileNotFoundError),改动前后都存在,
与本 PR 无关。

另外单独核对过增量结果的正确性:把 mfundinfo("000198") 的净值表截去 6 行后调用 update(),
重建出的净值与完整抓取的表在 6 位小数上完全一致。

天天基金已下线 fund.eastmoney.com/f10/F10DataApi.aspx,该地址现 302
跳转至 fundf10.eastmoney.com/F10DataApi.aspx 并返回 404。

该页面是 fundinfo.update 与 mfundinfo.update 的数据来源,因此在存在
本地缓存副本后,所有场外基金的增量更新都会抛出 HttpStatusError:首次
抓取走 pingzhongdata 正常,之后每次更新都失败。

改用 api.fund.eastmoney.com/f10/lsjz,JSON 字段与原表格列一一对应
(FSRQ/DWJZ/LJJZ/FHSP),服务端每页 20 条的上限不变,请求带上
fundf10.eastmoney.com referer。

tests/test_info.py::test_fund_update 在修改前报 HttpStatusError,
修改后通过。
@refraction-ray
refraction-ray merged commit a1dcc7a into refraction-ray:master Jul 25, 2026
1 of 2 checks passed
@refraction-ray

Copy link
Copy Markdown
Owner

感谢贡献,确实存在该问题!

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.

2 participants