{"id":50057556,"url":"https://github.com/simonlin1212/a-stock-data","last_synced_at":"2026-06-07T06:00:36.332Z","repository":{"id":357298834,"uuid":"1235056479","full_name":"simonlin1212/a-stock-data","owner":"simonlin1212","description":"A股全栈数据工具包 — 7层架构 · 27端点 · 13数据源 · 零第三方依赖 | Full-stack China A-Share data toolkit for AI coding assistants","archived":false,"fork":false,"pushed_at":"2026-06-03T15:36:31.000Z","size":240,"stargazers_count":3328,"open_issues_count":9,"forks_count":690,"subscribers_count":21,"default_branch":"main","last_synced_at":"2026-06-03T17:14:22.053Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simonlin1212.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"buy_me_a_coffee":"simonlin1212","custom":["https://ifdian.net/a/simonlin"]}},"created_at":"2026-05-11T01:08:15.000Z","updated_at":"2026-06-03T17:04:51.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/simonlin1212/a-stock-data","commit_stats":null,"previous_names":["simonlin1212/a-stock-data"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/simonlin1212/a-stock-data","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonlin1212%2Fa-stock-data","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonlin1212%2Fa-stock-data/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonlin1212%2Fa-stock-data/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonlin1212%2Fa-stock-data/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simonlin1212","download_url":"https://codeload.github.com/simonlin1212/a-stock-data/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonlin1212%2Fa-stock-data/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34010556,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-07T02:00:07.652Z","response_time":124,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-05-21T15:00:44.305Z","updated_at":"2026-06-07T06:00:36.326Z","avatar_url":"https://github.com/simonlin1212.png","language":null,"funding_links":["https://buymeacoffee.com/simonlin1212","https://ifdian.net/a/simonlin"],"categories":["开源工具"],"sub_categories":["好用工具"],"readme":"# a-stock-data\n\nA 股全栈数据工具包 — 7 层架构 · 27 个端点 · 13 个数据源 · 零第三方数据封装依赖\n\n一个自包含的 Skill 文件，把分散在 13 个数据源里的 A 股原始数据整合成 AI 编程助手直接能用的工具集。你不用再背 mootdx 的 K 线参数、东财的 PDF Referer 头、iwencai 的 X-Claw 鉴权——全部封装好了。\n\n\u003e **V3.2.2 修复（2026-06-03）：** ① **概念板块归属（#18）**——百度 PAE `getrelatedblock` 失效（`ResultCode 10003`）→ 改用东财 `slist` 一次拿全个股所属板块（行业/概念/地域 + BK码 + 涨跌幅 + 龙头股）；② **巨潮公告 orgId（#19）**——硬编码 `gssx0{code}` 导致大量 601xxx 股票查不到公告 → 改为动态查官方映射表 `szse_stock.json`（6198 只股）；③ 修复综合示例对已删函数 `baidu_fund_flow_history` 的调用；④ §4.5/§5.1 加大陆住宅 IP 间歇风控说明。\n\u003e\n\u003e **V3.2（2026-05-30）：** ① **数据源优先级 + 东财防封**——优先用通达信(mootdx)/腾讯（不封 IP），东财仅用于其独有数据，并新增统一节流入口 `em_get()`，所有东财接口内置串行限流（间隔≥1s+随机抖动）+ 会话复用，AI 抄代码即自带防封；② **财联社快讯下线（#14）**——`cls.cn` 旧 API 全面 404，改用东财全球资讯。\n\u003e\n\u003e **V3.1 修复（2026-05-19）：** 替换 4 个失效接口（百度 PAE 资金流→东财 push2、大宗交易/机构席位报表名更新）+ 修复东财全球资讯和巨潮公告参数变更。\n\u003e\n\u003e **V3.0 Breaking Change：** 彻底移除 akshare 依赖，所有数据源改为直连 HTTP API。新增资金面/筹码层。\n\n\u003e 兼容 [Claude Code](https://github.com/anthropics/claude-code) · [Codex](https://github.com/openai/codex) · [OpenClaw](https://github.com/anthropics/openclaw)\n\u003e\n\u003e Skill 文件本质是结构化 Markdown + 内嵌 Python，任何支持上下文注入的 AI 编程助手都能用。\n\n---\n\n## 架构\n\n```\nA 股全栈数据 · 七层架构 · V3.2.2\n│  （优先级：mootdx/腾讯 不封IP 优先用；东财仅用于独有数据，已内置限流防封）\n├── 行情层    mootdx + 腾讯财经 + 百度K线   K线(带MA5/10/20) + 五档盘口 + PE/PB/市值 + 指数/ETF\n├── 研报层    东财 reportapi + 同花顺 + iwencai  研报列表 / PDF下载 / 一致预期 / NL搜索\n├── 信号层    同花顺 + 东财                  强势股 + 题材归因 + 北向资金 + 板块归属\n│                                           + 资金流向(push2) + 龙虎榜 + 全市场龙虎榜 + 解禁 + 行业对比\n├── 资金面    东财 datacenter + push2        融资融券 + 大宗交易 + 股东户数 + 分红送转 + 资金流(分钟+120日)\n├── 新闻层    东财（直连HTTP）              个股新闻 / 全球资讯（财联社快讯已下线）\n├── 基础数据  mootdx + 东财 + 新浪           季报37字段 / F10九大类 / 财报三表\n└── 公告层    巨潮 cninfo + mootdx           沪深北全量公告\n```\n\n---\n\n## 快速开始\n\n**3 步，2 分钟。**\n\n```bash\n# 1. 创建 skill 目录\nmkdir -p ~/.claude/skills/a-stock-data\n\n# 2. 把 SKILL.md 放进去\ncurl -o ~/.claude/skills/a-stock-data/SKILL.md \\\n  https://raw.githubusercontent.com/simonlin1212/a-stock-data/main/SKILL.md\n\n# 3. 安装依赖（V3.0 不再需要 akshare）\npip install mootdx requests pandas stockstats\n```\n\n启动 Claude Code，说一句「帮我看看 688017 的估值」，自动激活。\n\n\u003e **Codex / OpenClaw 用户：** 把 SKILL.md 的内容贴入你的系统 prompt 或项目上下文文件即可，内嵌的 Python 代码可直接执行。\n\n---\n\n## 27 个端点能力清单\n\n### 行情层（实时，不封 IP）\n\n| 端点 | 数据 |\n|------|------|\n| mootdx 行情 | K线(多周期) + 五档盘口 + 逐笔成交 + 实时报价 46 字段 |\n| 腾讯财经 | PE(TTM) / PB / 总市值 / 流通市值 / 换手率 / 涨跌停价 / 指数 / ETF |\n| **百度K线** | 日K线 + MA5/MA10/MA20 均价直接返回（V3.0 新增） |\n\n### 研报层\n\n| 端点 | 数据 |\n|------|------|\n| 东财 reportapi | 研报列表 + 评级 + 三年 EPS 预测 |\n| 东财 PDF 下载 | 完整研报 PDF（已处理 Referer 鉴权） |\n| 同花顺一致预期 | 机构一致预期 EPS（直连 basic.10jqka.com.cn） |\n| iwencai NL 搜索 | 自然语言跨主题研报检索 |\n\n### 信号层\n\n| 端点 | 数据 |\n|------|------|\n| 同花顺热点 | 当日强势股 + 题材归因 reason tags（编辑部人工标注） |\n| 同花顺北向（实时） | 沪股通 / 深股通分钟级流向（262 个时间点） |\n| 同花顺北向（历史） | 本地自缓存日级历史 |\n| 东财板块归属 | 个股所属全部板块（行业/概念/地域混合）+ BK码 + 当日涨跌幅 + 龙头股（V3.2.2 替换百度 PAE，一次请求拿全）|\n| **东财资金流向** | 主力 / 大单 / 中单 / 小单 / 超大单分钟级净流入（V3.1 替换百度 PAE） |\n| 龙虎榜席位 | 上榜记录 + 买卖席位 TOP5 + 机构动向 |\n| 全市场龙虎榜 | 每日全市场上榜股票 + 净买额排名 + 上榜原因 |\n| 限售解禁日历 | 历史解禁 + 未来 90 天待解禁预警 |\n| **行业板块排名** | 东财行业涨跌/上涨下跌家数（V3.0 替换同花顺，零鉴权） |\n\n### 资金面 / 筹码层（V3.0 新增）\n\n| 端点 | 数据 |\n|------|------|\n| **融资融券明细** | 日级融资余额/买入/偿还 + 融券余额/卖出/偿还 |\n| **大宗交易** | 成交价/量 + 买卖方营业部 + 溢价率 |\n| **股东户数变化** | 季度股东数 + 环比变化 + 户均持股（筹码集中度） |\n| **分红送转历史** | 每股派息/送股/转增 + 进度状态 |\n| **个股资金流120日** | 主力/大单/中单/小单日级净流入 |\n\n### 新闻层\n\n| 端点 | 数据 |\n|------|------|\n| 个股新闻 | 东财个股新闻流（直连 search-api-web） |\n| ~~财联社快讯~~ | ⚠️ 已下线（cls.cn 迁 Next.js，旧 API 404，#14）→ 用全球资讯替代 |\n| 全球资讯 | 东财全球财经资讯（直连 np-weblist，7×24） |\n\n### 基础数据 + 公告\n\n| 端点 | 数据 |\n|------|------|\n| 季报快照 | 37 字段（EPS / ROE / 净利润 / 主营收入...） |\n| F10 公司资料 | 9 大类文本（截断优化，-70% token） |\n| 东财个股信息 | 行业/总股本/流通股/市值/上市日期（直连 push2） |\n| 新浪财报三表 | 资产负债表/利润表/现金流量表（直连 quotes.sina.cn） |\n| 巨潮公告 | 沪深北交所全量公告 |\n\n### 鉴权要求\n\n除 iwencai 外，其余所有数据源**完全免费无 Key**。仅 iwencai 语义搜索需要 API Key（[申请地址](https://www.iwencai.com/skillhub)）。\n\n---\n\n## 使用示例\n\n跟你的 AI 助手说这些话就能激活：\n\n| 场景 | 说什么 |\n|------|--------|\n| 个股估值 | 「帮我估一下 688017，给我 PE / PEG / 消化时间」 |\n| 题材归因 | 「今天哪些股票走强，主要是什么题材」 |\n| 研报检索 | 「人形机器人产业链最近的研报，特别是丝杠和减速器」 |\n| 北向资金 | 「今天北向资金流入流出怎么样」 |\n| 概念板块 | 「688017 属于哪些概念板块」 |\n| 资金流向 | 「000858 今天主力资金流入还是流出」 |\n| 龙虎榜 | 「002475 最近上过龙虎榜吗，哪些营业部在买」 |\n| 全市场龙虎榜 | 「今天龙虎榜哪些票净买入最多」 |\n| 解禁预警 | 「这只股票未来 3 个月有没有限售解禁」 |\n| 行业轮动 | 「今天哪些行业涨幅最大，资金在流入哪些板块」 |\n| 融资融券 | 「600519 最近的融资余额变化趋势」 |\n| 大宗交易 | 「这只票最近有没有大宗交易，溢价还是折价」 |\n| 股东户数 | 「000858 股东户数在增加还是减少，筹码集中吗」 |\n| 分红送转 | 「茅台历年分红派息多少」 |\n| 新闻公告 | 「拉一下 300476 最近的新闻和公告」 |\n| 批量对比 | 「帮我对比这 5 只半导体股的估值」 |\n\n### 内置 4 套调研流程\n\n| 流程 | 做什么 | 耗时 |\n|------|--------|------|\n| 单票估值 | 实时价 → 一致预期 EPS → 前向 PE / PEG / PE 消化年数 | 30 秒 |\n| 批量对比 | 多只股票横向估值排列 | 1 分钟 |\n| 主题研报 | iwencai 多关键词 NL 搜索 + 东财 PDF 交叉补充 | 2 分钟 |\n| 新标的调研 | 机构覆盖 → 估值 → 概念板块 → 资金流向 → 龙虎榜 → 解禁 → 两融 | 1 分钟 |\n\n---\n\n## V3.2.2 亮点\n\n| 变化 | 说明 |\n|------|------|\n| **概念板块归属换源（#18）** | 百度 PAE `getrelatedblock` 失效（`ResultCode 10003`）→ 改用东财 `slist`，一次请求拿全个股所属板块（行业/概念/地域 + BK码 + 涨跌幅 + 龙头股），零鉴权走 `em_get` 限流 |\n| **巨潮公告 orgId 动态化（#19）** | 硬编码 `gssx0{code}` 导致大量 601xxx 股票（平安/工行/中石油等）查不到公告 → 动态查官方映射表 `szse_stock.json`（6198 只股，模块级缓存），硬编码降为 fallback |\n| **修复综合示例隐藏崩溃** | 示例仍调用 v3.1 已删除的 `baidu_fund_flow_history` → 改为 `eastmoney_fund_flow_minute` |\n| **大陆住宅 IP 风控说明** | §4.5 资金流 / §5.1 新闻 加 ⚠️：部分大陆住宅 IP 会被东财间歇风控（`HTTP 000`/空），非代码问题，重试或换网络即可 |\n| **数据源优先级原则**（V3.2 起） | 明确「能用通达信(mootdx)/腾讯就别用东财」——前两者 TCP/HTTP 实测不封 IP，可放心高频；东财仅用于其独有数据 |\n| **东财统一限流防封** | 新增节流入口 `em_get()`，所有东财端点（datacenter/push2/reportapi/search/np-weblist）改用它，内置串行限流（间隔≥1s+随机抖动）+ 会话复用，批量抄代码即自带防封 |\n| **东财风控阈值文档化** | SKILL 新增「数据源优先级 \u0026 东财防封」章节，列出触发封禁的阈值（每秒\u003e5/并发≥10/1分≥200/5分≥300）与防封铁律 |\n| **财联社快讯下线（#14）** | `cls.cn` 旧 API 全面 404，标注弃用，改用东财全球资讯 |\n\n---\n\n## 数据源优先级（V3.2 重排，按封 IP 风险）\n\n\u003e **原则：行情/K线/实时价/市值/财务能从 mootdx 或腾讯拿到的，一律优先用它们（不封 IP）。东财只用于它独有、别处拿不到的数据，且全部走 `em_get()` 内置限流。**\n\n| 优先级 | 数据源 | 协议 | 封 IP 风险 | 用途 |\n|--------|--------|------|-----------|------|\n| **1（首选）** | mootdx（通达信） | TCP 7709 | **不封 IP** | K线/五档/逐笔/财务快照/F10 |\n| **2（首选）** | 腾讯财经 | HTTP | **不封 IP** | 实时价/PE/PB/市值/换手率/涨跌停/指数/ETF |\n| 3 | 同花顺热点/北向 | HTTP | 极低（零鉴权） | 强势股/题材归因/北向资金 |\n| 4 | 百度股市通 | HTTP | 极低 | K线（带 MA5/10/20）|\n| 5 | 新浪财经 | HTTP | 低 | 财报三表 |\n| 6 | 巨潮 cninfo | HTTP | 低 | 公告全文 |\n| 7 | 同花顺一致预期 | HTTP | 低（需 UA） | EPS 一致预期 |\n| 8 | iwencai | OpenAPI | 低（需 Key） | NL 语义搜索 |\n| **末位（仅独有数据）** | **东财** datacenter/push2/reportapi/search/np-weblist | HTTP | **中 — 有风控会封 IP** | 龙虎榜/解禁/两融/大宗/股东户数/分红/资金流/研报/个股新闻/全球资讯（已统一走 `em_get()` 限流） |\n\n\u003e **架构原则：** 除 mootdx（TCP 二进制协议）外，全部直连 HTTP API，零第三方数据封装依赖。**东财系接口有访问频率风控，所有调用统一经 `em_get()` 串行限流防封；批量任务请调大 `EM_MIN_INTERVAL`。**\n\n---\n\n## FAQ\n\n**Q: mootdx 和腾讯有什么区别？**\n互补。mootdx = 交易层（价格 + 盘口 + K 线），腾讯 = 估值层（PE / PB / 市值 / 换手率 / 涨跌停价）。两者都不封 IP。\n\n**Q: 在海外服务器跑，mootdx 超时？**\nmootdx 走 TCP 直连通达信行情服务器，需国内 IP 才稳定。海外环境建议走代理或切换到 yfinance。\n\n**Q: 腾讯 API 字段 43 是 PB 吗？**\n不是。43 = 振幅%，46 = PB。网上大量教程写错了，这里是实测校准结果。\n\n**Q: V3.0 为什么移除 akshare？**\nakshare 本质是对东财/同花顺/新浪等公开 API 的封装，中间层增加了故障点（版本兼容 bug、pandas 3.0 ArrowInvalid 等）。V3.0 直连底层 HTTP API，零中间依赖，更稳定可控。\n\n**Q: 行业板块为什么从同花顺换成东财？**\n同花顺 `stock_board_industry_summary_ths` 接口 2026 年初加了反爬 401。东财 push2 行业板块（`m:90+t:2`）是完美替代，零鉴权且字段更丰富。\n\n**Q: iwencai 返回 401？**\n检查：(1) API Key 有效性 (2) 是否携带了 X-Claw-* Headers。SkillHub 2.0 后强制要求。\n\n**Q: 同花顺热点 reason 字段为空？**\n盘后数据还没更新，15:30 之后再调。个别 ST 股没有人工标注，`dropna` 过滤即可。\n\n**Q: 百度股市通 ResultCode 不稳定？**\n已知坑——有时返回 int `0`，有时返回 string `\"0\"`。代码里用 `str()` 统一比较即可。\n\n**Q: 东财资金流/个股新闻偶尔返回空或 HTTP 000？（#18）**\n部分**大陆住宅宽带 IP** 会被东财 push2/search-api 连接级间歇风控（表现 `HTTP 000` 连接被拒、或新闻只返回 `passportWeb` 无文章）。**这不是代码问题**——同一代码在其他网络/时段实测正常。对策：隔几分钟重试、换网络环境（手机热点）、调大 `EM_MIN_INTERVAL` 降频。日级资金流也可用 mootdx 量价数据务实替代。\n\n**Q: 北向资金历史只有几天？**\nV2.1 改为本地自缓存。每次调用自动积累，越跑越丰富。首次运行只有当天数据。\n\n**Q: 不用 Claude Code，能用吗？**\n能。SKILL.md 本质是 Markdown + 内嵌 Python 代码。Codex、OpenClaw 或任何 AI 编程助手都能读取。你也可以直接把 Python 代码段复制出来在自己的脚本里跑。\n\n---\n\n## 更新日志\n\n见 [CHANGELOG.md](./CHANGELOG.md)。\n\n---\n\n## Donate\n\n如果这个工具帮到了你的投研工作流，欢迎请作者喝杯咖啡 ☕\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./assets/wechat-sponsor.jpg\" width=\"240\" alt=\"微信赞赏码\"\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://ifdian.net/a/simonlin\"\u003e爱发电\u003c/a\u003e ·\n  \u003ca href=\"https://buymeacoffee.com/simonlin1212\"\u003eBuy Me a Coffee\u003c/a\u003e\n\u003c/p\u003e\n\n\u003e 想要什么数据端点？欢迎开 [Issue](https://github.com/simonlin1212/a-stock-data/issues) 提需求，赞助者的 Issue 优先处理。\n\n---\n\n## Disclaimer\n\n本项目仅提供数据获取工具，不构成任何投资建议。股市有风险，投资需谨慎。\n\n---\n\n## License\n\n[Apache License 2.0](./LICENSE) — 自由使用，注明出处即可。\n\n**作者：** Simon 林 · 抖音「Simon林」 · 公众号「硅基世纪」\n\n---\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003e🇬🇧 English\u003c/b\u003e\u003c/summary\u003e\n\n# a-stock-data\n\nFull-stack data toolkit for China A-Share market — 7-layer architecture · 27 endpoints · 13 data sources · zero third-party data wrapper dependencies\n\nA self-contained Skill file that consolidates raw A-share data from 13 sources into a ready-to-use toolkit for AI coding assistants. No need to memorize mootdx candlestick parameters, Eastmoney PDF Referer headers, or iwencai X-Claw authentication — it's all handled.\n\n\u003e **V3.2.2 Fix (2026-06-03):** ① **Sector/concept membership (#18)** — Baidu PAE `getrelatedblock` is dead (`ResultCode 10003`) → switched to Eastmoney `slist`, fetching all of a stock's sectors (industry/concept/region + BK code + change% + leading stock) in one request. ② **cninfo filing orgId (#19)** — hardcoded `gssx0{code}` made many 601xxx tickers return zero filings → now resolves the real orgId dynamically from the official map `szse_stock.json` (6198 stocks). ③ Fixed a crash in the combined example calling the removed `baidu_fund_flow_history`. ④ Added notes on intermittent Eastmoney throttling for some mainland residential IPs.\n\u003e\n\u003e **V3.2 (2026-05-30):** ① **Data-source priority + Eastmoney anti-ban** — prefer mootdx (TDX) / Tencent (never IP-banned); use Eastmoney only for its exclusive data, all routed through a new throttled `em_get()` (serial rate-limit ≥1s + jitter + session reuse) so copied code is ban-safe by default. ② **Cailianpress (cls.cn) deprecated (#14)** — old API returns 404, replaced by Eastmoney global news.\n\u003e\n\u003e **V3.1 Fix (2026-05-19):** Replaced 4 broken endpoints (Baidu PAE fund flow → Eastmoney push2, block trade/institution report name updates) + fixed Eastmoney global news and cninfo filing parameter changes.\n\u003e\n\u003e **V3.0 Breaking Change:** Completely removed akshare dependency. All data sources now use direct HTTP API calls. Added capital flow / ownership layer.\n\n\u003e Compatible with [Claude Code](https://github.com/anthropics/claude-code) · [Codex](https://github.com/openai/codex) · [OpenClaw](https://github.com/anthropics/openclaw)\n\u003e\n\u003e The Skill file is structured Markdown + embedded Python. Any AI coding assistant with context injection can use it.\n\n---\n\n## Architecture\n\n```\nChina A-Share Full-Stack Data · 7-Layer Architecture · V3.2.2\n│  (Priority: prefer mootdx/Tencent — never IP-banned; Eastmoney only for exclusive data, with built-in throttling)\n├── Market Data    mootdx + Tencent + Baidu K-line   Candlesticks (w/ MA5/10/20) + Order Book + PE/PB + Index/ETF\n├── Research       Eastmoney + THS + iwencai          Report list / PDF / Consensus EPS / NL search\n├── Signals        THS + Eastmoney                    Hot stocks + Sector attribution + Northbound flow\n│                                                     + Sector membership + Fund flow(push2) + Dragon Tiger + Lockup + Industry\n├── Capital Flow   Eastmoney datacenter + push2       Margin trading + Block trades + Holder count + Dividends + Fund flow(min+120d)\n├── News           Eastmoney (direct HTTP)            Stock news / Global finance (CLS flash deprecated)\n├── Fundamentals   mootdx + Eastmoney + Sina          37-field quarterly + F10 9 categories + Financial statements\n└── Filings        cninfo + mootdx                    Full filings across SSE / SZSE / BSE\n```\n\n---\n\n## Quick Start\n\n**3 steps, 2 minutes.**\n\n```bash\n# 1. Create skill directory\nmkdir -p ~/.claude/skills/a-stock-data\n\n# 2. Download SKILL.md\ncurl -o ~/.claude/skills/a-stock-data/SKILL.md \\\n  https://raw.githubusercontent.com/simonlin1212/a-stock-data/main/SKILL.md\n\n# 3. Install dependencies (V3.0: akshare no longer needed)\npip install mootdx requests pandas stockstats\n```\n\nLaunch Claude Code and say \"Check the valuation of 688017\" — the skill activates automatically.\n\n\u003e **Codex / OpenClaw users:** Paste the contents of SKILL.md into your system prompt or project context file. The embedded Python code is ready to execute.\n\n---\n\n## 27 Endpoints\n\n### Market Data (real-time, no IP ban)\n\n| Endpoint | Data |\n|----------|------|\n| mootdx Market Data | Candlesticks (multi-period) + Level-2 order book + tick-by-tick + 46-field quote |\n| Tencent Finance | PE(TTM) / PB / Market Cap / Float Cap / Turnover / Price Limits / Index / ETF |\n| **Baidu K-line** | Daily K-line + MA5/MA10/MA20 moving averages included (V3.0 new) |\n\n### Research Reports\n\n| Endpoint | Data |\n|----------|------|\n| Eastmoney reportapi | Report list + ratings + 3-year EPS forecasts |\n| Eastmoney PDF | Full research report PDF (Referer auth handled) |\n| THS Consensus EPS | Institutional consensus EPS (direct basic.10jqka.com.cn) |\n| iwencai NL Search | Natural language cross-topic report search |\n\n### Signals\n\n| Endpoint | Data |\n|----------|------|\n| THS Hot Stocks | Today's strong stocks + sector attribution tags (editorial annotations) |\n| THS Northbound (real-time) | Shanghai/Shenzhen Connect minute-level flow (262 data points) |\n| THS Northbound (historical) | Local self-cached daily history |\n| Eastmoney Sector Membership | All sectors a stock belongs to (industry/concept/region mixed) + BK code + daily change + leading stock (V3.2.2, replaced Baidu PAE, one request) |\n| **Eastmoney Fund Flow** | Main / Large / Medium / Small / Super-large order minute-level net inflow (V3.1, replaced Baidu PAE) |\n| Dragon Tiger Board | Appearance records + Top 5 buy/sell brokerages + institutional activity |\n| Daily Dragon Tiger (Full Market) | All stocks on daily board + net buy ranking + appearance reasons |\n| Lockup Expiry Calendar | Historical releases + 90-day upcoming expiry alerts |\n| **Industry Ranking** | Eastmoney industry change/up/down counts (V3.0, replaced THS 401) |\n\n### Capital Flow / Ownership (V3.0 New)\n\n| Endpoint | Data |\n|----------|------|\n| **Margin Trading** | Daily margin balance / buy / repay + short selling balance |\n| **Block Trades** | Deal price/volume + buyer/seller brokerages + premium rate |\n| **Shareholder Count** | Quarterly holder count + QoQ change + avg shares per holder |\n| **Dividend History** | Per-share cash dividend / bonus shares / transfer shares |\n| **120-Day Fund Flow** | Main / large / medium / small order daily net inflow |\n\n### News\n\n| Endpoint | Data |\n|----------|------|\n| Stock News | Eastmoney per-stock news (direct search-api-web) |\n| ~~CLS Flash~~ | ⚠️ Deprecated (cls.cn migrated to Next.js, old API 404, #14) → use Global News |\n| Global News | Eastmoney global finance news (direct np-weblist, 7×24) |\n\n### Fundamentals + Filings\n\n| Endpoint | Data |\n|----------|------|\n| Quarterly Snapshot | 37 fields (EPS / ROE / Net Profit / Revenue...) |\n| F10 Company Data | 9 categories (truncation optimization, -70% tokens) |\n| Eastmoney Stock Info | Industry / total shares / float / market cap / listing date (direct push2) |\n| Sina Financial Statements | Balance sheet / Income statement / Cash flow (direct quotes.sina.cn) |\n| cninfo Filings | Full filings across all exchanges |\n\n### Authentication\n\nAll data sources except iwencai are **completely free, no API key needed**. Only iwencai semantic search requires an API key ([apply here](https://www.iwencai.com/skillhub)).\n\n---\n\n## Usage Examples\n\nJust tell your AI assistant:\n\n| Scenario | Prompt |\n|----------|--------|\n| Valuation | \"Estimate 688017 — give me PE / PEG / payback period\" |\n| Sector Attribution | \"Which stocks are strong today and what sectors are driving them\" |\n| Research Reports | \"Latest reports on humanoid robot supply chain, especially ball screws and reducers\" |\n| Northbound Flow | \"How's northbound capital flow looking today\" |\n| Concept Blocks | \"What concept sectors does 688017 belong to\" |\n| Fund Flow | \"Is institutional money flowing into or out of 000858 today\" |\n| Dragon Tiger Board | \"Has 002475 appeared on the dragon tiger board recently, which brokerages are buying\" |\n| Daily Dragon Tiger | \"Which stocks had the highest net buy on today's dragon tiger board\" |\n| Lockup Expiry | \"Any lockup expiries coming up in the next 3 months for this stock\" |\n| Industry Rotation | \"Which industries are up the most today, where is money flowing\" |\n| Margin Trading | \"What's the recent trend in margin balance for 600519\" |\n| Block Trades | \"Any recent block trades for this stock, premium or discount\" |\n| Shareholder Count | \"Is 000858 shareholder count increasing or decreasing\" |\n| Dividends | \"How much has Moutai paid in dividends over the years\" |\n| News \u0026 Filings | \"Pull recent news and filings for 300476\" |\n| Batch Compare | \"Compare valuations of these 5 semiconductor stocks\" |\n\n### 4 Built-in Research Workflows\n\n| Workflow | What it does | Time |\n|----------|-------------|------|\n| Single Stock Valuation | Live price → Consensus EPS → Forward PE / PEG / PE payback years | 30 sec |\n| Batch Comparison | Side-by-side valuation ranking | 1 min |\n| Thematic Research | iwencai multi-keyword NL search + Eastmoney PDF cross-reference | 2 min |\n| New Target Research | Coverage → Valuation → Concepts → Fund flow → Dragon tiger → Lockup → Margin | 1 min |\n\n---\n\n## V3.2.2 Highlights\n\n| Change | Description |\n|--------|-------------|\n| **Sector membership re-sourced (#18)** | Baidu PAE `getrelatedblock` is dead (`ResultCode 10003`) → switched to Eastmoney `slist`; one request returns all of a stock's sectors (industry/concept/region + BK code + change% + leading stock), no auth, throttled via `em_get` |\n| **cninfo orgId resolved dynamically (#19)** | Hardcoded `gssx0{code}` made many 601xxx tickers (Ping An / ICBC / PetroChina, etc.) return zero filings → now resolves the real orgId from the official map `szse_stock.json` (6198 stocks, module-level cache), hardcode kept as fallback |\n| **Fixed hidden crash in combined example** | Example still called the v3.1-removed `baidu_fund_flow_history` → switched to `eastmoney_fund_flow_minute` |\n| **Mainland residential IP throttling note** | §4.5 fund flow / §5.1 news: some mainland residential IPs hit intermittent Eastmoney throttling (`HTTP 000` / empty) — not a code bug, retry or switch network |\n| **Data-source priority principle** (since V3.2) | Prefer mootdx (TDX) / Tencent — both never IP-banned in practice, safe for high-frequency use. Use Eastmoney only for its exclusive data |\n| **Unified Eastmoney throttling** | New `em_get()` entry point; all Eastmoney endpoints (datacenter/push2/reportapi/search/np-weblist) route through it with built-in serial rate-limit (≥1s + jitter) + session reuse — copied code is ban-safe by default |\n| **Eastmoney rate-limit documented** | New \"Data-source priority \u0026 Eastmoney anti-ban\" section lists ban thresholds (\u003e5/s, ≥10 concurrent, ≥200/min, ≥300/5min) and anti-ban rules |\n| **Cailianpress deprecated (#14)** | cls.cn old API returns 404 — marked deprecated, replaced by Eastmoney global news |\n\n---\n\n## Data Source Priority (V3.2 re-ranked by IP-ban risk)\n\n\u003e **Principle: anything available from mootdx or Tencent (quotes / K-line / live price / market cap / financials) must use them first (never IP-banned). Eastmoney is only for its exclusive data, all routed through the throttled `em_get()`.**\n\n| Priority | Source | Protocol | IP Ban Risk | Use |\n|----------|--------|----------|-------------|-----|\n| **1 (top)** | mootdx (TDX) | TCP 7709 | **Never banned** | K-line / order book / ticks / financials / F10 |\n| **2 (top)** | Tencent Finance | HTTP | **Never banned** | Live price / PE / PB / market cap / turnover / index / ETF |\n| 3 | THS Hot Stocks / Northbound | HTTP | Very low (zero auth) | Hot stocks / themes / northbound flow |\n| 4 | Baidu Finance | HTTP | Very low | K-line (w/ MA5/10/20) |\n| 5 | Sina Finance | HTTP | Low | Financial statements |\n| 6 | cninfo | HTTP | Low | Filings |\n| 7 | THS Consensus EPS | HTTP | Low (UA required) | Consensus EPS |\n| 8 | iwencai | OpenAPI | Low (key required) | NL semantic search |\n| **last (exclusive only)** | **Eastmoney** datacenter/push2/reportapi/search/np-weblist | HTTP | **Medium — has rate-limit risk** | Dragon-tiger / lockup / margin / block trade / shareholders / dividends / fund flow / reports / news (all via `em_get()`) |\n\n\u003e **Architecture:** Except mootdx (TCP binary protocol), all sources use direct HTTP API calls, zero third-party data wrapper dependencies. **Eastmoney APIs are rate-limited; all calls go through `em_get()` for serial throttling. For batch jobs, increase `EM_MIN_INTERVAL`.**\n\n---\n\n## Disclaimer\n\nThis project provides data access tools only and does not constitute investment advice. Investing involves risk.\n\n---\n\n## License\n\n[Apache License 2.0](./LICENSE)\n\n**Author:** Simon Lin · TikTok [@simonlin121212](https://www.tiktok.com/@simonlin121212) · Douyin \"Simon林\" · WeChat Official Account \"硅基世纪\"\n\n\u003c/details\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonlin1212%2Fa-stock-data","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimonlin1212%2Fa-stock-data","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonlin1212%2Fa-stock-data/lists"}