astock-data-source

astock-data-source is a skill for Claude Code, Codex from ZICXR/A-Stock-Skills. It costs 104 tokens per session (1,006 once invoked), scanned A, original, MIT.

A tool for retrieving Chinese A-share stock data from several online sources. A-shares are stocks listed on mainland Chinese exchanges; the tool covers prices, charts, company information, news, and related data.

In plain words
What is it for?
Use it to fetch real-time prices, historical K-line data, index data, stock information, and company news through command-line commands.
Why use it?
It reduces dependence on one data provider by retrying requests and switching sources when a provider fails. It also provides health checks for the available sources.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to fetch real-time prices, historical K-line data, index data, stock information, and company news through command-line commands.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/zicxr/a-stock-skills/astock-data-source
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add ZICXR/A-Stock-Skills --skill astock-data-source
Clone the repo
git clone --depth 1 https://github.com/ZICXR/A-Stock-Skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for astock-data-source

README.md
[![agentmods](https://agentmods.dev/badge/skills/zicxr/a-stock-skills/astock-data-source/github.svg)](https://agentmods.dev/skills/zicxr/a-stock-skills/astock-data-source)
Your own site
<a href="https://agentmods.dev/skills/zicxr/a-stock-skills/astock-data-source"><img src="https://agentmods.dev/badge/skills/zicxr/a-stock-skills/astock-data-source/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for astock-data-source

Your own site · 80×15
<a href="https://agentmods.dev/skills/zicxr/a-stock-skills/astock-data-source"><img src="https://agentmods.dev/badge/skills/zicxr/a-stock-skills/astock-data-source.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 104 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,006 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00104 $0.01006
Opus 5 $0.00052 $0.00503
Sonnet 5 $0.00021 $0.00201
Haiku 4.5 $0.00010 $0.00101

Measured 12d ago against content hash 76b5b1d52f36, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, from the pricing page.

Security

Grade A, and why

astock-data-source scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 12d ago.

The scan reads SKILL.md. This mod also ships 1 executable file (main.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/01-infra/astock-data-source/SKILL.md · 116 lines

What it actually says

A 股多源数据源管理 Skill (v2.0)

何时使用

  • 用户需要获取股票数据
  • 用户需要稳定的 API 封装
  • 用户在住宅网络环境下使用
  • 任何需要 A 股数据的 Skill

⚠️ 重要更新 (v2.0)

修复了住宅 IP 数据源被封问题:

优先级 数据源 实测可用 备注
1️⃣ ifzq gtimg (腾讯) ✅ 90%+ 住宅 IP 首选
2️⃣ 新浪 hq.sinajs.cn ✅ 80%+ 全市场列表也用这个
3️⃣ 东财 push2.eastmoney ❌ 30% 经常被封, 仅作备用
4️⃣ akshare ✅ 85% 聚合源, fallback

自动 fallback 机制:

  • 每个数据源连续失败 3 次自动跳过
  • 支持多源切换, 不再硬抛"所有数据源失败"
  • 修复了 Windows GBK 编码问题
  • 修复了 akshare 内部代理问题

🏃 快速验证 (网络环境测试)

# 测试你的网络环境
python main.py healthcheck

# 输出示例:
# === 数据源健康检查 ===
#   ✅ ifzq_gtimg
#   ✅ sina_hq
#   ❌ eastmoney_push2 (被风控, 已自动跳过)
#   ✅ sina 全市场: 5028 只

提供能力

行情

  • get-realtime --code X - 单股实时 (多源)
  • get-realtime-all - 全 A 股实时 (用新浪)
  • get-kline --code X --days N - K 线 (用 ifzq)

指数

  • get-index-realtime - 主要指数
  • get-index-kline --symbol X - 指数 K 线

其他

  • get-stock-info --code X - 股票信息
  • get-news --code X - 个股新闻
  • healthcheck - 数据源健康检查

使用方式

命令行 (新规范)

# ✅ 正确: 用 --code 命名参数
python main.py get-realtime --code 601991
python main.py get-kline --code 601991 --days 60

# ✅ 正确: --list 列出方法
python main.py --list

# ❌ 旧版 (已废弃): 位置参数
python main.py get-realtime 601991

Python API

from skills.01-infra.astock-data-source.main import (
    get_realtime, get_realtime_all, get_kline
)

# 单股 (自动多源 fallback)
quote = get_realtime("601991")

# 全 A 股
all_stocks = get_realtime_all()

# K 线
df = get_kline("601991", days=60)

故障速查

现象 原因 解决
ProxyError: 7890 代理挡住外网 切到 ifzq/sina
RemoteDisconnected 东财被封 等待 3 次后自动切
UnicodeEncodeError (Win) GBK 编码 已自动修复
所有数据源失败 网络隔离 运行 healthcheck 检查

依赖

requests>=2.28.0
akshare>=1.12.0
pandas>=1.5.0

实测状态

  • 2026-06-21: 住宅 IP 验证通过, ifzq + sina 稳定可用
  • 2026-05-03: 旧版在住宅 IP 100% 失败 (已修复)
Files

What ships with it

4 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 12d ago First seen · 116 lines · 104 tokens per session scan A 76b5b1d52f36

Subscribe to this mod's changes

astock-data-source is a skill published in the GitHub repository ZICXR/A-Stock-Skills (25 stars, last pushed 2mo ago), licensed MIT. It adds 104 tokens to every session and 1,006 once invoked, about $0.0005 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.