Stock Unified
多源统一股票数据接口,整合通达信(pytdx)/同花顺/东方财富(新版API)/akshare五大股票数据源,自动降级切换。用于A股实时行情查询、K线历史、板块排行与成分股、财务数据、板块搜索等场景。当用户查询股价、板块排行、成分股、K线、财务数据时使用。
Clement Gu
@clementgu
What This Skill Does
Unified command-line interface for Chinese A-share stock data that aggregates five data sources (Tongdaxin, East Money, Tonghuashun, akshare, Sina Finance) with automatic fallback. Supports real-time quotes, K-line history, sector rankings, sector constituent stocks, and financial data.
Eliminates the need to manually switch between multiple stock data APIs by providing a single CLI with automatic source degradation and consistent output.
When to Use It
- Query real-time stock prices and index values for A-share market
- Retrieve historical K-line data for technical analysis
- Get sector/industry rankings with top gainers and capital flows
- Look up constituent stocks of a specific sector or concept
- Fetch financial statements and key metrics for a listed company
- Search for sector codes by keyword to find relevant stock groups
Install
$ openclaw skills install @clementgu/stock-unified🐂 UnifiedStock — 多源统一股票数据接口 v3.0
A股 5 大数据源自动整合:通达信(pytdx) + 东方财富(新版datacenter API) + 同花顺(ths) + akshare + 新浪财经。
🆕 v3.0 更新:
- ✅ 实时行情改新浪优先(快+稳),通达信补充交易时段数据
- ✅ 指数代码支持:000001→上证指数、399001→深证成指、399006→创业板指等
- ✅ 开盘前智能显示:⏰ 未开盘 + 昨收价,不再空白
- ✅ 上证的盘前参考价自动识别并显示
安装依赖
pip install pytdx akshare requests pandas
数据源自动降级策略
实时行情: 新浪财经(sina) → 通达信(pytdx) → akshare
K线历史: 通达信(pytdx) → akshare
板块排行: 同花顺(ths) → akshare
板块成分股: 东方财富(datacenter) → akshare
财务数据: akshare
每个源挂了自动换下一个,无需手动指定。
快速上手指南
1️⃣ 查实时行情(支持股票+指数)
python3 scripts/unified_stock.py --realtime 000001,600839,002156
⚠️ 000001 自动识别为上证指数(不是平安银行), 399001 → 深证成指
输出:代码、最新价、涨跌幅、昨收、成交量、未开盘标记
2️⃣ 查K线
python3 scripts/unified_stock.py --kline 600839 --days 30
默认最近 10 天,支持任意天数。
3️⃣ 板块排行
python3 scripts/unified_stock.py --sector-top 20
输出行业板块 Top N:涨跌幅、涨跌家数、资金净流入、领涨股。
4️⃣ 板块成分股
# 先搜板块代码
python3 scripts/unified_stock.py --search 半导体
# 再查成分股
python3 scripts/unified_stock.py --sector-stocks 917
python3 scripts/unified_stock.py --sector-stocks 917 --live # 带实时行情
板块代码说明:917=半导体概念, 891=国产芯片, 952=第三代半导体, 1137=存储芯片
5️⃣ 财务数据
python3 scripts/unified_stock.py --financial 600839
6️⃣ JSON 输出
所有命令支持 --json 参数,方便程序调用:
python3 scripts/unified_stock.py --realtime 600839 --json
python3 scripts/unified_stock.py --sector-top 10 --json
7️⃣ 数据源检测
python3 scripts/unified_stock.py --status
板块代码参考(常用)
| 代码 | 板块 | 成分股数 |
|---|---|---|
| 917 | 半导体概念 | ~480 |
| 891 | 国产芯片 | ~250 |
| 952 | 第三代半导体 | ~150 |
| 1137 | 存储芯片 | ~80 |
| 1037 | 消费电子 | ~200 |
| 1201 | 电子 | ~300 |
可用 --search 搜索任意关键词找到代码。
架构
统一入口 unified_stock.py
├── 实时行情 → tdx_get_quotes() [通达信]
├── K线 → tdx_get_kline() [通达信]
├── 板块排行 → ths_industry_summary() [同花顺]
├── 板块成分股 → east_get_board_stocks() [东方财富]
├── 财务数据 → ak_get_financial() [akshare]
└── 状态检测 → get_status() [全部源]
Python API:
from unified_stock import get_realtime, get_kline, get_sector_top, get_sector_stocks
# 查行情
quotes = get_realtime(["600839", "002156", "002475"])
# 查K线
kline = get_kline("600839", days=30)
# 板块排行
sectors = get_sector_top(20)
# 板块成分股(带实时价)
stocks = get_sector_stocks("917", live=True)
# 数据源状态
status = get_status()
Top skills in this category
Stock Analysis
@udiedrichsenAnalyze stocks and cryptocurrencies using Yahoo Finance data. Supports portfolio management, watchlists with alerts, dividend analysis, 8-dimension stock scoring, viral trend detection (Hot Scanner), and rumor/early signal detection. Use for stock analysis, portfolio tracking, earnings reactions, crypto monitoring, trending stocks, or finding rumors before they hit mainstream.
Stock Market Pro
@kys42Yahoo Finance (yfinance) powered stock analysis skill: quotes, fundamentals, ASCII trends, high-resolution charts (RSI/MACD/BB/VWAP/ATR), plus optional web a...
A股量化 AkShare
@mbpzA股量化数据分析工具,基于AkShare库获取A股行情、财务数据、板块信息等。用于回答关于A股股票查询、行情数据、财务分析、选股等问题。
Stock Watcher
@robin797860Manage and monitor a personal stock watchlist with support for adding, removing, listing stocks, and summarizing their recent performance using data from 10jqka.com.cn. Use when the user wants to track specific stocks, get performance summaries, or manage their watchlist.
Intelligent Stocks Screener
@financial-ai-analyst基于东方财富数据库,支持通过自然语言输入筛选A港美股、基金、债券等多种资产,支持多元指标筛选,含技术面、消息面、基本面及市场情绪等,可用于全球资产速筛、跨市场监控、投资组合构建、策略回测等场景。返回结果包含数据说明及 csv 文件。Natural language screener for investment...