Akshare A Shares

by Yrzhe

api

针对中国A股的行情与数据查询(基于本地 akshare 源代码与API映射)。当用户请求获取A股实时行情、历史K线(日/周/月)、分钟级分时(1/5/15/30/60)、复权数据(前复权/后复权)、股东户数(含详情)、以及巨潮资讯公告披露结果时使用本Skill。默认优先使用东方财富(EM)接口;如用户指定新浪(Sina)来源或需要特定接口,则按映射调用对应函数。可使用内置脚本输出CSV/JSON,或内联Python调用。

Skill Details

Repository Files

406 files in this skill directory


name: akshare-a-shares description: 针对中国A股的行情与数据查询(基于本地 akshare 源代码与API映射)。当用户请求获取A股实时行情、历史K线(日/周/月)、分钟级分时(1/5/15/30/60)、复权数据(前复权/后复权)、股东户数(含详情)、以及巨潮资讯公告披露结果时使用本Skill。默认优先使用东方财富(EM)接口;如用户指定新浪(Sina)来源或需要特定接口,则按映射调用对应函数。可使用内置脚本输出CSV/JSON,或内联Python调用。

A股数据查询(akshare)

本Skill指导如何基于本地 akshare 源码目录的数据接口完成 A 股数据查询,并提供一个可直接运行的脚本以便快速拉取数据。

目录约定:本地 akshare 源位于 Recents/akshare(相对当前工作目录)。如不一致,请在执行脚本前修改脚本内 AK_PATH

快速开始

  • 方式一(推荐)脚本直取:使用 scripts/akshare_fetch.py 拉取数据,支持 CSV 或 JSON 输出。
    • 示例见 references/examples.md
  • 方式二 内联Python:在任务中按“接口映射”选定函数与参数,直接编写最小可运行代码。

核心流程

  1. 识别用户意图与来源
    • 行情总览(实时行情)、历史K线(日/周/月)、分钟分时、复权、股东户数、公告检索等
    • 来源优先级:未指定则默认 EastMoney(EM);用户指明“新浪”则用 Sina 接口
  2. 选择接口与参数
    • references/endpoints.md 的“意图→接口”映射与参数说明
  3. 拉取与校验
    • 使用脚本或内联Python调用;如返回为空,检查代码格式(是否需交易所前缀、日期格式、是否退市等)
  4. 返回结果
    • 表格/CSV/JSON;必要时附带参数回显与数据来源

接口映射总览(最常用)

  • 实时全市场 A 股:stock_feature.stock_hist_em.stock_zh_a_spot_em()
  • 历史K线(日/周/月,支持复权):stock_feature.stock_hist_em.stock_zh_a_hist(symbol, period, start_date, end_date, adjust)
  • 分钟分时(1/5/15/30/60,支持复权):stock_feature.stock_hist_em.stock_zh_a_hist_min_em(symbol, start_date, end_date, period, adjust)
  • 股东户数(批量/季度末):stock_feature.stock_gdhs.stock_zh_a_gdhs(symbol);详情:stock_feature.stock_gdhs.stock_zh_a_gdhs_detail_em(symbol)
  • 公告披露(巨潮资讯):stock_feature.stock_disclosure_cninfo.stock_zh_a_disclosure_report_cninfo(...)stock_zh_a_disclosure_relation_cninfo(...)
  • 新浪来源(如指定):实时报价 stock.stock_zh_a_sina.stock_zh_a_spot()、日线/复权 stock.stock_zh_a_sina.stock_zh_a_daily(...)、分钟线 stock.stock_zh_a_sina.stock_zh_a_minute(...)

详细参数、示例与注意事项见 references/endpoints.mdreferences/examples.md

使用内置脚本

脚本路径:scripts/akshare_fetch.py

  • 基本用法(CSV):
    • python3 scripts/akshare_fetch.py spot --source em --format csv
    • python3 scripts/akshare_fetch.py hist --symbol 600519 --period daily --start 20200101 --end 20251231 --adjust qfq --format csv
    • 更多示例见 references/examples.md

脚本特性:

  • 自动将 Recents/akshare 加入 sys.path,直接导入本地 akshare 源
  • 默认输出到标准输出;--format json 输出JSON
  • 依赖:python3pandasrequests(Sina 接口还需 py_mini_racer
  • 若依赖缺失,会给出友好错误提示

符号与日期规范

  • EM 接口通常使用纯数字代码:沪市以 6 开头(如 600519),深市以 0/3 开头(如 000001
  • Sina 接口部分函数使用带交易所前缀的代码(如 sh600519sz000001
  • 日期:YYYYMMDD(日/周/月K);分钟分时使用 YYYY-MM-DD HH:MM:SS
  • 复权:adjust 取值 { "": 不复权, "qfq": 前复权, "hfq": 后复权 }

仅在需要时阅读的参考

  • references/endpoints.md:接口清单、参数与返回字段概述
  • references/examples.md:常见请求的可直接运行示例及脚本命令

请按需加载参考文件,避免无关内容占用上下文。

Related Skills

Reactome Database

Query Reactome REST API for pathway analysis, enrichment, gene-pathway mapping, disease pathways, molecular interactions, expression analysis, for systems biology studies.

apidata

Mermaid Diagrams

Comprehensive guide for creating software diagrams using Mermaid syntax. Use when users need to create, visualize, or document software through diagrams including class diagrams (domain modeling, object-oriented design), sequence diagrams (application flows, API interactions, code execution), flowcharts (processes, algorithms, user journeys), entity relationship diagrams (database schemas), C4 architecture diagrams (system context, containers, components), state diagrams, git graphs, pie charts,

artdesigncode

Polars

Fast DataFrame library (Apache Arrow). Select, filter, group_by, joins, lazy evaluation, CSV/Parquet I/O, expression API, for high-performance data analysis workflows.

workflowapidata

Reactome Database

Query Reactome REST API for pathway analysis, enrichment, gene-pathway mapping, disease pathways, molecular interactions, expression analysis, for systems biology studies.

apidata

Mermaidjs V11

Create diagrams and visualizations using Mermaid.js v11 syntax. Use when generating flowcharts, sequence diagrams, class diagrams, state diagrams, ER diagrams, Gantt charts, user journeys, timelines, architecture diagrams, or any of 24+ diagram types. Supports JavaScript API integration, CLI rendering to SVG/PNG/PDF, theming, configuration, and accessibility features. Essential for documentation, technical diagrams, project planning, system architecture, and visual communication.

artdocumentapi

Monitoring Apis

|

api

Validating Performance Budgets

Validate application performance against defined budgets to identify regressions early. Use when checking page load times, bundle sizes, or API response times against thresholds. Trigger with phrases like "validate performance budget", "check performance metrics", or "detect performance regression".

api

Tracking Application Response Times

Track and optimize application response times across API endpoints, database queries, and service calls. Use when monitoring performance or identifying bottlenecks. Trigger with phrases like "track response times", "monitor API performance", or "analyze latency".

apidata

Databuddy

Integrate Databuddy analytics into applications using the SDK or REST API. Use when implementing analytics tracking, feature flags, custom events, Web Vitals, error tracking, LLM observability, or querying analytics data programmatically.

apidata

Datasette Plugin Writer

Guide for writing Datasette plugins. This skill should be used when users want to create or develop plugins for Datasette, including information about plugin hooks, the cookiecutter template, database APIs, request/response handling, and plugin configuration.

templateapidata

Skill Information

Category:Technical
Last Updated:1/29/2026