cn-stock-data
中国A股/港股/美股统一数据抽象层。屏蔽 akshare/efinance/adata/pysnowball/ashare 五个数据源的 API 差异,提供统一代码格式(SH600519)、统一字段名(英文 snake_case)、智能路由和自动 Fallback。当用户需要获取股票行情、实时报价、资金流向、财务指标、北向资金等金融数据时使用此 skill。
Best use case
cn-stock-data is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
中国A股/港股/美股统一数据抽象层。屏蔽 akshare/efinance/adata/pysnowball/ashare 五个数据源的 API 差异,提供统一代码格式(SH600519)、统一字段名(英文 snake_case)、智能路由和自动 Fallback。当用户需要获取股票行情、实时报价、资金流向、财务指标、北向资金等金融数据时使用此 skill。
Teams using cn-stock-data should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/cn-stock-data/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How cn-stock-data Compares
| Feature / Agent | cn-stock-data | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
中国A股/港股/美股统一数据抽象层。屏蔽 akshare/efinance/adata/pysnowball/ashare 五个数据源的 API 差异,提供统一代码格式(SH600519)、统一字段名(英文 snake_case)、智能路由和自动 Fallback。当用户需要获取股票行情、实时报价、资金流向、财务指标、北向资金等金融数据时使用此 skill。
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# cn-stock-data 统一金融数据层
## 核心能力
- **统一代码格式**: `SH600519` / `SZ000001` / `HK00700` / `AAPL.O`,也接受纯数字 `600519`(自动推断市场)
- **统一返回字段**: 英文 snake_case(date, open, close, high, low, volume, amount, pct_change 等)
- **智能路由**: 每种数据类型有最优源优先级链,自动 fallback
- **跨市场**: 港股/美股自动路由到 pysnowball
## 数据类型 & 路由优先级
| 类型 | 命令 | 路由链 |
|------|------|--------|
| K线 | `kline` | efinance → akshare → adata → ashare → snowball |
| 实时行情 | `quote` | efinance → adata → snowball |
| 资金流向 | `fund_flow` | efinance → adata → snowball |
| 财务指标 | `finance` | adata(43字段) → akshare → snowball |
| 北向资金 | `north_flow` | adata(独占) |
| 跨市场 | 自动 | snowball(独占) |
## CLI 用法
```bash
SCRIPTS_DIR="$SKILLS_ROOT/cn-stock-data/scripts"
# K线(日/周/月/分钟)
python "$SCRIPTS_DIR/cn_stock_data.py" kline --code SH600519 --freq daily --start 2026-01-01
# 实时行情(支持多只,逗号分隔)
python "$SCRIPTS_DIR/cn_stock_data.py" quote --code SH600519,SZ000001
# 跨市场行情(自动路由到 snowball)
python "$SCRIPTS_DIR/cn_stock_data.py" quote --code HK00700,AAPL.O
# 资金流向
python "$SCRIPTS_DIR/cn_stock_data.py" fund_flow --code SZ000001
# 财务指标
python "$SCRIPTS_DIR/cn_stock_data.py" finance --code SH600519
# 北向资金
python "$SCRIPTS_DIR/cn_stock_data.py" north_flow
# 强制指定数据源
python "$SCRIPTS_DIR/cn_stock_data.py" kline --code SH600519 --source akshare
# 检查各源可用状态
python "$SCRIPTS_DIR/cn_stock_data.py" status
```
## 统一返回格式(JSON)
```json
{
"ok": true,
"source": "efinance",
"fallback_used": false,
"code": "SH600519",
"data_type": "kline",
"count": 30,
"data": [
{"date": "2026-03-14", "open": 1880.0, "close": 1895.5, "high": 1900.0, "low": 1875.0, "volume": 25000, "amount": 47000000, "pct_change": 0.82}
]
}
```
## 频率参数
`--freq`: daily, weekly, monthly, 1min, 5min, 15min, 30min, 60min
## 代码格式支持
| 输入 | 解析结果 |
|------|---------|
| `SH600519` | 上交所贵州茅台 |
| `SZ000001` | 深交所平安银行 |
| `600519` | 自动推断→SH600519 |
| `000001` | 自动推断→SZ000001 |
| `HK00700` | 港股腾讯 |
| `AAPL.O` | 美股苹果 |
## 编程接口(Python import)
```python
import sys; sys.path.insert(0, "$SKILLS_ROOT/cn-stock-data/scripts")
from routing import execute_with_fallback, get_available_sources
# K线
result = execute_with_fallback("kline", "get_kline", code="SH600519", freq="daily", start="2026-01-01")
if result["ok"]:
for row in result["data"][:3]:
print(row)
# 行情
result = execute_with_fallback("quote", "get_quote", code="SH600519", codes=["SH600519", "SZ000001"])
# 状态检查
print(get_available_sources())
```
## 注意事项
- pysnowball 的 kline/finance/fund_flow 需要 token(从 xueqiu.com cookie 获取),无 token 时自动跳过
- ashare 只支持 K 线(日/周/月/分钟),无行情/资金流/财务
- akshare K 线只支持日/周/月,不支持分钟级
- 分钟级 K 线优先用 efinance,fallback 到 ashareRelated Skills
zhitu-data
智兔数服数据Skill - 免注册A股/港股/基金实时行情、历史K线、技术指标 via 智兔数服
pysnowball-data
雪球(Snowball)金融数据接口,提供 A 股/港股/美股实时行情、财务报表(资产负债/利润/现金流)、估值指标、资金流向、行业对比、基金净值、可转债、指数数据。当用户需要雪球数据、跨市场行情(A/港/美)、财务报表详情、或雪球独有的业务分析数据时使用此 skill。pysnowball 的独特优势:(1)跨市场覆盖(A/港/美)(2)财务三表完整数据 (3)行业对比分析 (4)机构持仓变动。注意:部分高级接口需要雪球 token,基础行情(quotec)无需 token。
fred-data
美联储 FRED 经济数据库接口,提供美国 GDP、CPI、就业、利率、通胀等核心经济指标。当用户需要查询美国经济数据时使用。
efinance-data
efinance 中国金融市场数据获取工具,封装 A 股行情、资金流向、龙虎榜、十大股东、业绩报表、基金净值持仓、可转债、期货等数据接口。当用户需要获取 A 股实时行情、个股资金流、主力动向、龙虎榜、十大股东变动、业绩数据、基金净值或持仓、可转债或期货行情时使用此 skill。也适用于需要中国金融市场数据来支撑投研分析、个股研究、行业对比、资产配置等场景。与 akshare-finance 互补,efinance 在资金流分层(主力/大单/超大单)和实时行情字段丰富度上更有优势。
ecb-data
欧央行(ECB)经济数据查询,提供欧元区基准利率、CPI、GDP 及主要成员国经济数据。当用户需要查询欧洲经济数据或欧央行政策时使用。
dd-data-gap-alert
用于信托领域项目尽调中的尽调资料缺口提示助手场景。支持结构化输入处理、规则分析与Markdown结果输出。
data-consistency-check
用于信托领域合规与运营中的数据一致性核验助手场景,支持结构化处理与报告输出。
data-cleaner
金融数据清洗与异常检测工具,提供缺失值处理、去重、异常值检测、数据标准化等功能。当用户需要对原始金融数据进行预处理时使用。
boj-data
日本央行(BOJ)经济数据查询,提供日本基准利率、CPI、GDP、货币政策等宏观数据。当用户需要查询日本经济数据或日央行政策时使用。
baostock-history
历史行情数据Skill - 提供A股/指数/基金的完整历史K线数据,支持前复权/后复权,适合回测研究 via BaoStock
bank-t241-transaction-banking-inclusive-finance-data-validation-assistant
当用户需要在银行交易银行与普惠场景下,围绕数据核验进行完整性、一致性、真实性或规则符合性检查时使用本技能。适合输出核验结论、异常项清单、补件要求和升级复核建议。
ashare-data
Ashare 最轻量 A 股行情获取工具(3.2k Stars),基于新浪+腾讯双核心数据源,零依赖(仅需 requests+pandas),无需注册,支持日/周/月线及 1m/5m/15m/30m/60m 分钟级K线。当用户需要快速获取 A 股/指数行情而其他数据源不可用时,Ashare 是最可靠的回退方案——它使用新浪为主、腾讯为备的双核心架构,自动切换,极少出错。