akshare

akfamilyMIT活跃维护 有专家点评

开箱即用的 Python 财经数据接口库,一行代码就能拉取股票、债券、期货、外汇和宏观经济等公开数据,省去到处爬数据、清洗数据的麻烦。

AKShare is an elegant and simple financial data interface library for Python, built for human beings! 开源财经数据接口库

v1.20.37发布于 2026-11-09 16:32 UTC23,289star +33 / 7 天3,568fork同步于 2026-11-11 05:22 UTC

专家点评

上手难度:入门更新于 2026-11-11

用一行 pandas 调用替代自己爬东方财富/新浪的财经数据抓取层,覆盖 A 股、基金、债券、期货

适用场景

  • 量化研究做数据探索和因子原型:直接 ak.stock_zh_a_hist() 拿 DataFrame 进 pandas,省掉写爬虫和解析 JSON 的时间;自己维护抓取层的话,字段对齐和分页逻辑要重写一遍
  • 离线批量跑回测前的数据准备:按接口注册表批量拉全市场日线/财务数据落本地,再喂给 backtrader、vectorbt 这类框架;换成付费数据源成本高,换成自建爬虫维护量不成比例
  • 教学和学术复现:需要可复现的公开财经数据集时,接口名和参数在文档里固定,比让学生各自爬网站稳定
  • 给内部工具加 HTTP 数据层:装 AKTools 后把 AKShare 接口暴露成 HTTP/MCP,前端或 LLM agent 不用直接依赖 Python 环境

踩坑

  • 上游站点改版就会断:issue 里 stock_zh_a_hist 失效、东财换接口、stock_zh_a_spot_em() 只返回 200 行这类问题反复出现,说明接口稳定性不由本项目控制。生产环境用它必须自己加一层缓存和失败告警,不能把实时抓取放在关键路径上
  • 版本升级可能悄悄改行为:code_id_map_em 这类内部映射函数被用户改过才能用,意味着接口返回结构会随上游变化。锁版本 + 升级前跑一遍自己的数据校验
  • 环境门槛卡在 Python 版本:必须 64 位 Python 3.11+,老项目还在 3.8/3.9 的话装不上,得先升解释器或单独开虚拟环境
  • MCP/HTTP 服务不在主包里:README 明说 AKTools 是独立项目,想要 API 化要额外部署一个服务,不是 pip 装完就有

同类对比

需要稳定 SLA 和字段契约时选 Tushare Pro、Wind、聚宽这类付费源;只抓单一市场、接口简单时自己写 requests + pandas 反而更可控。AKShare 的定位是免费、广覆盖、可容忍偶发失效的探索层。

怎么上手

由 README 提炼,执行前请确认
pip install akshare --upgrade
硬件要求按 README 说明

README 未说明,仅要求 64 位 Python 3.11 或更高版本,无 GPU 或显存要求

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

Python 开源财经数据接口库,一行代码抓取股票、基金、债券等行情数据

开箱即用的 Python 财经数据接口库,一行代码就能拉取股票、债券、期货、外汇和宏观经济等公开数据,省去到处爬数据、清洗数据的麻烦。

核心能力

  • 一行代码调用接口直接返回 pandas 数据
  • 内置离线接口注册表,可按关键词搜索接口
  • 提供 interface_info 查询参数、输出列与示例
  • 配套 AKTools 提供 HTTP API 与 MCP 服务
  • 覆盖股票、基金、债券、期货等多类财经数据

容易踩的坑

需 64 位 Python 3.11 及以上版本,低版本无法安装;数据来自东方财富、新浪等第三方网站,接口可能因不可控因素被移除;MCP 与 HTTP API 需另装配套项目 AKTools,AKShare 本身不运行 MCP 服务

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v1.20.37
  1. v1.20.37最新正式版2026-11-09 · 2026-11-09 16:32 UTC

    这个版本没有写更新说明。

  2. v1.20.362026-11-08 · 2026-11-08 13:42 UTC

    这个版本没有写更新说明。

  3. v1.20.352026-11-06 · 2026-11-06 02:26 UTC

    这个版本没有写更新说明。

  4. v1.20.342026-11-05 · 2026-11-05 10:54 UTC

    这个版本没有写更新说明。

  5. v1.20.332026-11-05 · 2026-11-05 10:42 UTC

    这个版本没有写更新说明。

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    资源分享:对于想了解更多财经数据与量化投研的小伙伴,推荐一个专注于财经数据和量化研究的知识社区。 该社区提供相关文档和视频学习资源,汇集了各类财经数据源和量化投研工具的使用经验。 有兴趣深入学习的朋友可点此了解更多,也推荐大家关注微信公众号【数据科学实战】。

    重磅推荐:AKQuant 是一款专为 量化投研 (Quantitative Research) 打造的高性能量化回测框架。它以 Rust 铸造极速撮合内核, 以 Python 链接数据与 AI 生态,旨在为量化投资者提供可靠高效的量化投研解决方案。参见AKQuant

    工具推荐:期魔方是一款本地化期货量化分析工具,适合数据分析爱好者使用。无需复杂部署,支持数据分析和机器学习功能,研究功能免费开放。 如需了解更多信息可访问期魔方。

    AKShare Logo

    PyPI - Python Version PyPI PyPI Downloads Documentation Status Ruff akshare Checks Status Release Status MIT Licence

    Overview

    AKShare requires Python(64 bit) 3.11 or higher and aims to simplify the process of fetching financial data.

    Write less, get more!

    • Documentation: 中文文档
    • MCP server for AI assistants: AKTools lets Claude, Cursor and other MCP clients fetch AKShare data in natural language — see AI Assistants (MCP)
    • HTTP API: AKTools also serves AKShare over HTTP for other programming languages

    AI Assistants (MCP)

    AKShare is a Python library and does not run an MCP server itself. Its companion project AKTools ships one — registered in the official MCP Registry as io.github.akfamily/aktools — so AI assistants such as Claude Code, Claude Desktop and Cursor can look up and call every AKShare interface from a natural-language question, e.g. "贵州茅台 2024 年 10 月 8 日到 11 日的前复权日线行情".

    No separate install is needed beyond uv:

    claude mcp add aktools -- uvx --from aktools aktools-mcp
    

    Claude Desktop, Cursor and other clients:

    {
      "mcpServers": {
        "aktools": {
          "command": "uvx",
          "args": ["--from", "aktools", "aktools-mcp"]
        }
      }
    }
    

    Add AKTools MCP server to Cursor

    Instead of registering 1000+ tools, it exposes three generic ones that the assistant chains together:

    ToolPurpose
    search_interfacesFind interface names by keyword
    describe_interfaceShow an interface's parameters, defaults and description
    get_dataCall an interface and return up to max_rows rows (default 100, max 1000)

    A running python -m aktools server also exposes the same tools over Streamable HTTP at http://127.0.0.1:8080/mcp. See the MCP guide (中文) for HTTP mode, proxies, access tokens and LAN access.

    Installation

    uv (Recommended)

    uv pip install akshare --upgrade
    

    See the uv environment guide for installing uv and creating a virtual environment.

    pip

    pip install akshare --upgrade
    

    China

    uv pip install akshare --upgrade --default-index https://pypi.tuna.tsinghua.edu.cn/simple
    # or
    pip install akshare --upgrade -i https://pypi.tuna.tsinghua.edu.cn/simple
    

    Usage

    Data

    Code:

    import akshare as ak
    
    stock_zh_a_hist_df = ak.stock_zh_a_hist(symbol="000001", period="daily", start_date="20170301", end_date="20231022", adjust="")
    print(stock_zh_a_hist_df)
    

    Output:

          日期          开盘   收盘    最高  ...  振幅   涨跌幅  涨跌额  换手率
    0     2017-03-01   9.49   9.49   9.55  ...  0.84  0.11  0.01  0.21
    1     2017-03-02   9.51   9.43   9.54  ...  1.26 -0.63 -0.06  0.24
    2     2017-03-03   9.41   9.40   9.43  ...  0.74 -0.32 -0.03  0.20
    3     2017-03-06   9.40   9.45   9.46  ...  0.74  0.53  0.05  0.24
    4     2017-03-07   9.44   9.45   9.46  ...  0.63  0.00  0.00  0.17
              ...    ...    ...    ...  ...   ...   ...   ...   ...
    1610  2023-10-16  11.00  11.01  11.03  ...  0.73  0.09  0.01  0.26
    1611  2023-10-17  11.01  11.02  11.05  ...  0.82  0.09  0.01  0.25
    1612  2023-10-18  10.99  10.95  11.02  ...  1.00 -0.64 -0.07  0.34
    1613  2023-10-19  10.91  10.60  10.92  ...  3.01 -3.20 -0.35  0.61
    1614  2023-10-20  10.55  10.60  10.67  ...  1.51  0.00  0.00  0.27
    [1615 rows x 11 columns]
    

    Search

    AKShare ships an offline interface registry, so you can look up an interface by keyword without leaving Python and without any network request. This is especially handy for LLM-driven programs that need to resolve a description into a callable interface name.

    Code:

    import akshare as ak
    
    search_df = ak.search("可转债 实时行情", limit=5)
    print(search_df)
    
    # full metadata of a single interface: params, output columns and a usage example
    interface_info_dict = ak.interface_info("bond_cb_jsl")
    print(interface_info_dict)
    

    Output:

                          接口名    类目                                                       描述  有无文档   匹配分
    0             bond_cb_jsl  bond  集思录可转债实时数据,包含行情数据(涨跌幅,成交量和换手率等)及可转债基本信息(转股价,溢价率和到期收益率等)  True  27.0
    1      bond_zh_hs_cov_min  bond                                           东方财富网-可转债-分时行情  True  20.0
    2  bond_zh_hs_cov_pre_min  bond                                      东方财富网-可转债-分时行情-盘前分时  True  20.0
    3     bond_cov_comparison  bond                                   东方财富网-行情中心-债券市场-可转债比价表  True  17.0
    4        fund_etf_spot_em  fund                                            东方财富-ETF 实时行情  True  17.0
    

    Passing a full interface name always ranks that interface first, which makes it a reliable way to confirm a half-remembered name. Note this is keyword matching rather than semantic search — see the interface search docs for what it can and cannot do.

    Plot

    Code:

    import akshare as ak
    import mplfinance as mpf  # Please install mplfinance as follows: pip install mplfinance
    
    stock_us_daily_df = ak.stock_us_daily(symbol="AAPL", adjust="qfq")
    stock_us_daily_df = stock_us_daily_df.set_index(["date"])
    stock_us_daily_df = stock_us_daily_df["2020-04-01": "2020-04-29"]
    mpf.plot(stock_us_daily_df, type="candle", mav=(3, 6, 9), volume=True, show_nontrading=False)
    

    Features

    • Ease of use: Just one line code to fetch the data;
    • Extensible: Easy to customize your own code with other application;
    • Powerful: Python ecosystem.

    Tutorials

    1. Overview
    2. Installation
    3. Interface Search
    4. AI Assistants (MCP)
    5. Tutorial
    6. Data Dict
    7. Indicator
    8. FAQ
    9. Trade

    Contribution

    AKShare is still under development, feel free to open issues and pull requests:

    • Report or fix bugs
    • Require or publish interface
    • Write or fix documentation
    • Add test cases

    See the contributing guide before opening a pull request.

    Notice: We use Ruff to format the code

    Statement

    1. All data provided by AKShare is just for academic research purpose;
    2. The data provided by AKShare is for reference only and does not constitute any investment proposal;
    3. Any investor based on AKShare research should pay more attention to data risk;
    4. AKShare will insist on providing open-source financial data;
    5. Based on some uncontrollable factors, some data interfaces in AKShare may be removed;
    6. Please follow the relevant open-source protocol used by AKShare;
    7. Provide HTTP API and MCP server for other programming languages and AI assistants: AKTools.

    Show your style

    Use the badge in your project's README.md:

    [![Data: akshare](https://img.shields.io/badge/Data%20Science-AKShare-green)](https://github.com/akfamily/akshare)
    

    Using the badge in README.rst:

    .. image:: https://img.shields.io/badge/Data%20Science-AKShare-green
        :target: https://github.com/akfamily/akshare
    

    Looks like this:

    Data: akshare

    Citation

    Please use this bibtex if you want to cite this repository in your publications:

    @misc{akshare,
        author = {Albert King and Yaojie Zhang},
        title = {AKShare},
        year = {2022},
        publisher = {GitHub},
        journal = {GitHub repository},
        howpublished = {\url{https://github.com/akfamily/akshare}},
    }
    

    Acknowledgement

    Special thanks FuShare for the opportunity of learning from the project;

    Special thanks TuShare for the opportunity of learning from the project;

    Thanks for the data provided by 东方财富网站;

    Thanks for the data provided by 新浪财经网站;

    Thanks for the data provided by 金十数据网站;

    Thanks for the data provided by 生意社网站;

    Thanks for the data provided by 中国银行间市场交易商协会网站;

    Thanks for the data provided by 99期货网站;

    Thanks for the data provided by 中国外汇交易中心暨全国银行间同业拆借中心网站;

    Thanks for the data provided by 和讯财经网站;

    Thanks for the data provided by DACHENG-XIU 网站;

    Thanks for the data provided by 上海证券交易所网站;

    Thanks for the data provided by 深圳证券交易所网站;

    Thanks for the data provided by 北京证券交易所网站;

    Thanks for the data provided by 中国金融期货交易所网站;

    Thanks for the data provided by 上海期货交易所网站;

    Thanks for the data provided by 大连商品交易所网站;

    Thanks for the data provided by 郑州商品交易所网站;

    Thanks for the data provided by 上海国际能源交易中心网站;

    Thanks for the data provided by Timeanddate 网站;

    Thanks for the data provided by 河北省空气质量预报信息发布系统网站;

    Thanks for the data provided by Economic Policy Uncertainty 网站;

    Thanks for the data provided by 申万指数网站;

    Thanks for the data provided by 真气网网站;

    Thanks for the data provided by 财富网站;

    Thanks for the data provided by 中国证券投资基金业协会网站;

    Thanks for the data provided by Expatistan 网站;

    Thanks for the data provided by 北京市碳排放权电子交易平台网站;

    Thanks for the data provided by 国家金融与发展实验室网站;

    Thanks for the data provided by 义乌小商品指数网站;

    Thanks for the data provided by 百度迁徙网站;

    Thanks for the data provided by 思知网站;

    Thanks for the data provided by Currencyscoop 网站;

    Thanks for the data provided by 新加坡交易所网站;