feat: add akshare data loader for zero-auth A-share OHLCV panel - #42
Conversation
Add akshare as a new data source alongside baostock/yfinance/synthetic.
The loader follows the same pattern as baostock_loader.py: fetch -> pivot ->
build mask -> Panel.from_tensors(). Key differences from baostock:
- No login/logout (akshare requires zero authentication)
- Plain numeric ticker codes ("600519" instead of "sh.600000")
- Mask based on OHLCV completeness (akshare has no tradestatus field)
- VWAP always uses (O+C+H+L)/4 proxy, aligned with baostock v0.2.0 fix
Also adds make_panel(source="akshare", ...) support and mock tests.
Co-Authored-By: GPT-5.6-Sol (via Codex CLI) <noreply@anthropic.com>
initial-d
left a comment
There was a problem hiding this comment.
Thanks for adding this — the loader follows the existing Panel conventions cleanly, and the three Python CI jobs are green.
Before merging, please add the two public-surface pieces that are currently missing:
- Add a test that exercises
make_panel(source="akshare", ...)through the exported factory, not onlyload_akshare_panel(). That factory branch is part of the feature and is currently untested. - Document AkShare in the README data-source table and loader usage section. Please mention that it needs no API key, but relies on an upstream public-data interface that may change or rate-limit. Also update the
mlquant.datamodule/factory docstrings so the advertised source list is not stale.
No broader refactor is needed; the implementation itself looks consistent with the existing loaders.
initial-d
left a comment
There was a problem hiding this comment.
I completed the requested public-factory test and documentation directly on the PR branch. All Python 3.9, 3.10, and 3.11 CI jobs now pass, including Ruff, the full pytest suite, and the CLI smoke test. The requested changes are resolved.
|
Thanks for the contribution — this is a useful public-data addition. AkShare fills a different niche from Baostock: zero-auth A-share access for quick public-data experiments, while Baostock remains the more explicit login/session-backed path. I like that this PR kept the loader shape aligned with the existing Baostock panel contract instead of adding another abstraction layer. I'll treat this as part of the public-data validation surface for the next release notes. The main follow-up I would watch is provenance in reports: when a validation run uses |
做了什么
新增
akshare数据源加载器,让 ml-quant 支持通过 akshare(东方财富底层)获取 A 股日线 OHLCV 数据,无需注册或 API Key。改动范围
src/mlquant/data/akshare_loader.pysrc/mlquant/data/__init__.pymake_panel(source="akshare")tests/test_akshare.pypyproject.tomlakshare>=1.18.0设计决策
完全照搬既有 loader 模式——函数签名、错误处理、宽表转换、mask 构建均与
baostock_loader.py一致,新增代码不引入新的抽象层。和 baostock loader 的关键差异:
login()/logout()(akshare 零认证)"600519"而非"sh.600000")tradestatus字段)(O+C+H+L)/4代理——与 baostock v0.2.0 修复后的策略一致(akshare 复权后的 amount/volume 与 OHLC 不同基准)使用方式
验收
🤖 Generated with Claude Code
Co-Authored-By: GPT-5.6-Sol (via Codex CLI) noreply@anthropic.com