by akfamily
AKShare is an elegant and simple financial data interface library for Python, built for human beings! 开源财经数据接口库
# Add to your Claude Code skills
git clone https://github.com/akfamily/akshareGuides for using mcp servers skills like akshare.
akshare is an open-source mcp servers skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by akfamily. AKShare is an elegant and simple financial data interface library for Python, built for human beings! 开源财经数据接口库. It has 23,548 GitHub stars.
akshare's catalog security scan is still queued. You can run an instant dependency and prompt-injection check now with the "Scan for vulnerabilities" button above.
Clone the repository with "git clone https://github.com/akfamily/akshare" and add it to your Claude Code skills directory (see the Installation section above).
akshare is primarily written in Python. It is open-source under akfamily on GitHub, so you can review or fork the full source.
Yes. AgentsLLM lists many other MCP Servers skills you can browse and compare side by side. Open the MCP Servers category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh akshare against similar tools.
No comments yet. Be the first to share your thoughts!
Top skills in this category by stars
Unlocks once the catalog security scan passes (runs nightly).
The deep catalog scan for this skill is still queued. Run an instant dependency check now instead.
简体中文 | English
资源分享:对于想了解更多财经数据与量化投研的小伙伴,推荐一个专注于财经数据和量化研究的知识社区。 该社区提供相关文档和视频学习资源,汇集了各类财经数据源和量化投研工具的使用经验。 有兴趣深入学习的朋友可点此了解更多,也推荐大家关注微信公众号【数据科学实战】。
重磅推荐:AKQuant 是一款专为 量化投研 (Quantitative Research) 打造的高性能量化回测框架。它以 Rust 铸造极速撮合内核, 以 Python 链接数据与 AI 生态,旨在为量化投资者提供可靠高效的量化投研解决方案。参见AKQuant
工具推荐:期魔方是一款本地化期货量化分析工具,适合数据分析爱好者使用。无需复杂部署,支持数据分析和机器学习功能,研究功能免费开放。 如需了解更多信息可访问期魔方。

AKShare 是基于 Python 的开源财经数据接口库,目标是让获取财经数据变得简单,需要 64 位的 Python 3.11.5 或更高版本。
Write less, get more!
AKShare 是一个 Python 库,本身不提供 MCP 服务。配套项目 AKTools 提供了 MCP 服务,并以 io.github.akfamily/aktools 登记在 MCP 官方注册表中。Claude Code、Claude Desktop、Cursor 等 AI 助手可以根据一句自然语言的提问查找并调用 AKShare 的全部接口,例如“贵州茅台 2024 年 10 月 8 日到 11 日的前复权日线行情”。
只需要安装 uv,不必另外安装其他软件:
claude mcp add aktools -- uvx --from aktools aktools-mcp
Claude Desktop、Cursor 等客户端的配置:
{
"mcpServers": {
"aktools": {
"command": "uvx",
"args": ["--from", "aktools", "aktools-mcp"]
}
}
}
AKTools 没有把约 950 个接口逐个登记为工具,而是提供 3 个通用只读工具,由 AI 助手依次调用:
| 工具 | 用途 |
|---|---|
search_interfaces |
按关键词查找接口名 |
describe_interface |
查看接口的参数、默认值与说明 |
get_data |
调用接口,最多返回 max_rows 行(默认 100,最大 1000) |
stdio 方式下还有第 4 个工具 save_data(AKTools 0.1.12 起),可以把完整数据保存为本机 CSV 文件,不受 get_data 的 1000 行限制;它会写文件,没有标注为只读。
用 python -m aktools 启动的服务在 http://127.0.0.1:8080/mcp 以 Streamable HTTP 方式提供上述 3 个只读工具,不提供 save_data;完整数据可通过 get_data 返回的 CSV 下载地址获取。HTTP 方式、代理、访问令牌与局域网访问的设置见 MCP 使用指南。
uv pip install akshare --upgrade
uv 的安装与虚拟环境的创建见 uv 环境配置。
pip install akshare --upgrade
uv pip install akshare --upgrade --default-index https://pypi.tuna.tsinghua.edu.cn/simple
# 或者
pip install akshare --upgrade -i https://pypi.tuna.tsinghua.edu.cn/simple
代码:
import akshare as ak
stock_zh_a_hist_sina_df = ak.stock_zh_a_hist_sina(symbol="sz000001", period="daily", start_date="20170301", end_date="20231022", adjust="")
print(stock_zh_a_hist_sina_df)
输出:
date open high ... amount outstanding_share turnover
0 2017-03-01 9.49 9.55 ... 3.301580e+08 1.691799e+10 0.002051
1 2017-03-02 9.51 9.54 ... 3.823959e+08 1.691799e+10 0.002386
2 2017-03-03 9.41 9.43 ... 3.219525e+08 1.691799e+10 0.002025
3 2017-03-06 9.40 9.46 ... 3.812123e+08 1.691799e+10 0.002391
4 2017-03-07 9.44 9.46 ... 2.777474e+08 1.691799e+10 0.001742
... ... ... ... ... ... ... ...
1610 2023-10-16 11.00 11.03 ... 5.509887e+08 1.940555e+10 0.002585
1611 2023-10-17 11.01 11.05 ... 5.431709e+08 1.940555e+10 0.002543
1612 2023-10-18 10.99 11.02 ... 7.139799e+08 1.940555e+10 0.003359
1613 2023-10-19 10.91 10.92 ... 1.271915e+09 1.940555e+10 0.006127
1614 2023-10-20 10.55 10.67 ... 5.576186e+08 1.940555e+10 0.002711
[1615 rows x 9 columns]
AKShare 自带一份离线的接口登记,不必离开 Python、也不需要联网,就能按关键词查到接口。由大模型驱动的程序需要把一句描述对应到可调用的接口名时,这一功能尤其有用。
代码:
import akshare as ak
search_df = ak.search("可转债 实时行情", limit=5)
print(search_df)
# 单个接口的完整信息:参数、输出字段与调用示例
interface_info_dict = ak.interface_info("bond_cb_jsl")
print(interface_info_dict)
输出:
接口名 类目 描述 有无文档 匹配分
0 bond_cb_realtime_sina bond 新浪财经-沪深可转债数据 True 34.5
1 bond_cb_jsl bond 集思录可转债实时数据,包含行情数据(涨跌幅,成交量和换手率等)及可转债基本信息(转股价,溢价率和到期收益率等) True 28.5
2 bond_cb_info_em bond 东方财富网-数据中心-新股数据-可转债详情 True 15.0
3 bond_cb_list_em bond 东方财富网-数据中心-新股数据-可转债数据一览表 True 15.0
4 bond_cb_list_ths bond 同花顺-数据中心-可转债 True 15.0
传入完整的接口名时,该接口总是排在第一位,可以用来确认一个记不太清的名称。搜索是关键词匹配而不是语义检索,能做什么、不能做什么见接口检索文档。
接口名的结构是 <类目>_<市场或主体>_<主题>_<数据源>。以 stock_zh_a_hist_em 为例:类目 stock,市场 zh_a,主题 hist(历史行情),数据源 em(东方财富)。
ak.list_categories() 返回的 15 个类目之一:stock、index、fund、futures、option、bond、fx、macro、interest_rate、spot、energy、crypto、calendar、research、alternativeem、sina、ths、tx、cninfo、sse、szse,同一数据来自不同数据源时,接口名只有后缀不同daily 表示只有日线;带 period 参数(daily、weekly、monthly)的接口叫 hist,如 stock_zh_a_hist_em 和 stock_zh_a_hist_sina1.20.41 至 1.20.54 把所有接口统一到上面的命名规则:约 320 个接口改名(如 stock_zh_a_hist 改为 stock_zh_a_hist_em,stock_zh_index_daily 改为 index_zh_daily_sina),少数参数统一为 symbol、date、start_date、end_date,上游数据源已关闭的接口被移除。旧名称没有保留为别名,但调用时会提示去向:
import akshare as ak
ak.stock_zh_a_hist(symbol="000001")
# AttributeError: stock_zh_a_hist 已在 1.20.46 更名为 stock_zh_a_hist_em,请改用 ak.stock_zh_a_hist_em;…
ak.renamed_info("stock_zh_a_hist")
# {'name': 'stock_zh_a_hist', 'status': 'renamed', 'new_name': 'stock_zh_a_hist_em', 'version': '1.20.46', 'url': '…'}
用旧名称调用 ak.search 时,现在的名称也排在第一位。完整的新旧名称对照见更新日志末尾的接口更名一览表。
AKShare 仍在持续开发中,欢迎提交 issue 和 pull request:
提交 pull request 之前请先阅读贡献指南。
说明:本项目使用 Ruff 格式化代码
在项目的 README.md 中使用徽章:
[](https://github.com/akfamily/akshare)
在 README.rst 中使用徽章:
.. image:: https://img.shields.io/badge/Data%20Science-AKShare-green
:target: https://github.com/akfamily/akshare
显示效果:
在论文或出版物中引用本项目时,请使用下面的 bibtex:
@misc{akshare,
author = {Albert King and Yaojie Zhang},
title = {AKShare},
year = {2022},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/akfamily/akshare}},
}
特别感谢 [FuShare](https://g