Back to Registry
View Author Profile
Official Verified
Financial Market Data
Skill by bjdenglun
skill-install — Terminal
Install via CLI (Recommended)
clawhub install openclaw/skills/skills/bjdenglun/financial-market-dataOr
Financial Market Data Skill
统一金融行情数据接口 — 多源互补、自动降级、永不单点故障
安装指南(全新 OpenClaw 实例)
第一步:复制 Skill 目录
将整个 skills/financial-market-data/ 目录复制到目标机器的对应位置:
~/.openclaw/workspace/skills/financial-market-data/
目录结构:
financial-market-data/
├── SKILL.md # 本文件
├── skill.yaml # Skill 元数据
└── python/
├── pyproject.toml # Python 依赖
├── template.py # 基础接口(TickFlow/pytdx/baostock/akshare)
└── ths.py # 同花顺专用接口(新增)
第二步:安装 Python 依赖(推荐 uv)
cd ~/.openclaw/workspace
uv sync
或使用 pip:
pip install tickflow akshare baostock pytdx requests pandas
第三步:使用说明
在任意 Python 脚本中引用:
import sys
sys.path.insert(0, 'skills/financial-market-data/python')
from ths import get_daily_k, get_1min_k, get_intraday, get_realtime
from template import get_daily_k as tk_daily, get_realtime_eastmoney
一、同花顺数据接口 ✅ 推荐(无需注册,完全免费)
同花顺官方免费接口,1分钟K线最强(约821条历史,覆盖2009年至今)。
1.1 同花顺 日K线
import sys
sys.path.insert(0, 'skills/financial-market-data/python')
from ths import get_daily_k, get_daily_k_page
# 获取日K(每次最多140条,总量约3856条)
records = get_daily_k("300006") # 莱美药业
for r in records[-5:]:
print(r['date'], r['close'], r['volume'])
# 翻页获取更早数据(以第一条记录日期为end参数)
older = get_daily_k_page("300006", end_date="20250902")
1.2 同花顺 1分钟K线(最强免费源)
from ths import get_1min_k
# 获取1分钟K(全部历史,约821条)
records = get_1min_k("300006")
print(f"共 {len(records)} 条, {records[0]['date']} ~ {records[-1]['date']}")
优势对比:
| 数据源 | 1分钟K条数 | 免费 | 注册 |
|---|---|---|---|
| 同花顺 | 约821条 | ✅ | 不需要 |
| pytdx | 有限制 | ✅ | 不需要 |
| BaoStock | 有限制 | ✅ | 不需要 |
| 东方财富Level2 | 完整 | ❌ | 需要付费 |
1.3 同花顺 分时数据
from ths import get_intraday
# 获取分时(每分钟汇总,需差分计算增量)
result = get_intraday("300006")
for r in result['records'][-10:]:
print(r['time'], r['price'], r['volume'], '手/分钟')
1.4 同花顺 实时行情
from ths import get_realtime, get_multi_realtime
# 单只
rt = get_realtime("300006")
print(rt['price'])
# 批量
data = get_multi_realtime(["300006", "002560", "601975"])
for d in data:
print(d.get('code'), d.get('price'))
1.5 同花顺接口字段说明
| 周期 | URL路径 | 返回条数 | 数据格式 |
|---|---|---|---|
| 日K | /v6/line/hs_{code}/01/his.js | 140条/次,总3856条 | 日期,开,高,低,收,量,额,换手 |
| 1分钟K | /v6/line/hs_{code}/11/last.js | 全部约821条 | 同上 |
| 60分钟K | /v6/line/hs_{code}/60/last.js | 140条/次 | 日期时间(YYYYMMDDHHMM),开,高,低,收,量,额,换手 |
| 分时 | /v6/line/hs_{code}/01/last.js | 约140条/日 | 累计量,需差分算增量 |
| 实时 | /v6/realtime/hs_{code}.js | 1条即时 | 价格/高/低/量/额/五档 |
注意: 同花顺接口返回JSONP格式(
quotebridge_v6_line_hs_xxx({"num":...})),需解析JSONP并用分号分割数据字段。
二、A股日K线
2.1 TickFlow(推荐,接口简洁)
from tickflow import TickFlow
tf = TickFlow.free()
df = tf.klines.get("600519.SH", period="1d", count=100, as_dataframe=True)
# 返回字段:trade_date, open, high, low, close, volume
2.2 BaoStock(全量历史,支持复权)
Metadata
AI Skill Finder
Not sure this is the right skill?
Describe what you want to build — we'll match you to the best skill from 16,000+ options.
Find the right skill Add to Configuration
Paste this into your clawhub.json to enable this plugin.
{
"plugins": {
"official-bjdenglun-financial-market-data": {
"enabled": true,
"auto_update": true
}
}
}Safety NoteClawKit audits metadata but not runtime behavior. Use with caution.