← Back to Skills Marketplace
baostock_tt_skills
by
jasonpro22
· GitHub ↗
· v1.0.1
· MIT-0
264
Downloads
1
Stars
0
Active Installs
2
Versions
Install in OpenClaw
/install baostock-tt-skills
Description
获取A股历史K线数据、季频财务数据、宏观经济数据、板块成分股等
README (SKILL.md)
\r \r
BaoStock 金融数据技能\r
\r
调用免费开源的A股金融数据平台 - 无需注册即可获取历史K线、财务数据、宏观数据\r \r
安装\r
\r
pip install baostock\r
```\r
\r
## 快速开始\r
\r
```python\r
import baostock as bs\r
import pandas as pd\r
\r
# 登录系统\r
lg = bs.login()\r
print('login respond error_code:', lg.error_code)\r
print('login respond error_msg:', lg.error_msg)\r
\r
# 获取历史K线数据\r
rs = bs.query_history_k_data_plus(\r
"sh.600000",\r
"date,code,open,high,low,close,volume,amount",\r
start_date='2024-01-01',\r
end_date='2024-12-31',\r
frequency="d",\r
adjustflag="3"\r
)\r
\r
# 转换为DataFrame\r
data_list = []\r
while (rs.error_code == '0') & rs.next():\r
data_list.append(rs.get_row_data())\r
result = pd.DataFrame(data_list, columns=rs.fields)\r
print(result)\r
\r
# 登出系统\r
bs.logout()\r
```\r
\r
## API 清单\r
\r
### 1. 登录与登出\r
\r
| 函数 | 说明 |\r
|------|------|\r
| `login()` | 登录系统 |\r
| `logout()` | 登出系统 |\r
\r
### 2. 历史K线数据\r
\r
| 函数 | 说明 |\r
|------|------|\r
| `query_history_k_data_plus()` | 获取历史A股K线数据(日/周/月/分钟线) |\r
\r
**参数说明:**\r
- `code`: 股票代码(sh.600000 或 sz.000001)\r
- `fields`: 指标列表,逗号分隔\r
- `start_date`: 开始日期(YYYY-MM-DD)\r
- `end_date`: 结束日期(YYYY-MM-DD)\r
- `frequency`: 数据类型(d=日线, w=周线, m=月线, 5/15/30/60=分钟线)\r
- `adjustflag`: 复权类型(1=后复权, 2=前复权, 3=不复权)\r
\r
**常用指标:**\r
```\r
date,code,open,high,low,close,volume,amount,adjustflag,turn,tradestatus,pctChg\r
peTTM,pbMRQ,psTTM,pcfNcfTTM,isST\r
```\r
\r
### 3. 除权除息信息\r
\r
| 函数 | 说明 |\r
|------|------|\r
| `query_dividend_data()` | 查询除权除息信息 |\r
\r
**参数:**\r
- `code`: 股票代码\r
- `year`: 年份\r
- `yearType`: 年份类型(report=预案公告年份, operate=除权除息年份)\r
\r
### 4. 复权因子\r
\r
| 函数 | 说明 |\r
|------|------|\r
| `query_adjust_factor()` | 查询复权因子信息 |\r
\r
**参数:**\r
- `code`: 股票代码\r
- `start_date`: 开始日期\r
- `end_date`: 结束日期\r
\r
### 5. 季频财务数据\r
\r
| 函数 | 说明 |\r
|------|------|\r
| `query_profit_data()` | 季频盈利能力 |\r
| `query_operation_data()` | 季频营运能力 |\r
| `query_growth_data()` | 季频成长能力 |\r
| `query_balance_data()` | 季频偿债能力 |\r
| `query_cash_flow_data()` | 季频现金流量 |\r
| `query_dupont_data()` | 季频杜邦指数 |\r
\r
**参数:**\r
- `code`: 股票代码\r
- `year`: 统计年份\r
- `quarter`: 统计季度(1/2/3/4)\r
\r
**主要返回字段:**\r
- 盈利能力:roeAvg, npMargin, gpMargin, netProfit, epsTTM\r
- 营运能力:NRTurnRatio, INVTurnRatio, CATurnRatio\r
- 成长能力:YOYEquity, YOYNI, YOYEPSBasic\r
- 偿债能力:currentRatio, quickRatio, cashRatio\r
- 现金流量:CAToAsset, CFOToOR, CFOToNP\r
\r
### 6. 季频公司报告\r
\r
| 函数 | 说明 |\r
|------|------|\r
| `query_performance_express_report()` | 季频业绩快报 |\r
| `query_forecast_report()` | 季频业绩预告 |\r
\r
### 7. 证券基本资料\r
\r
| 函数 | 说明 |\r
|------|------|\r
| `query_stock_basic()` | 证券基本资料 |\r
\r
**参数:**\r
- `code`: 股票代码(可选)\r
- `code_name`: 股票名称(支持模糊查询)\r
\r
**返回字段:**\r
- code, code_name, ipoDate, outDate, type, status\r
\r
### 8. 证券元信息\r
\r
| 函数 | 说明 |\r
|------|------|\r
| `query_trade_dates()` | 交易日查询 |\r
| `query_all_stock()` | 证券代码查询 |\r
\r
### 9. 宏观经济数据\r
\r
| 函数 | 说明 |\r
|------|------|\r
| `query_deposit_rate_data()` | 存款利率 |\r
| `query_loan_rate_data()` | 贷款利率 |\r
| `query_required_reserve_ratio_data()` | 存款准备金率 |\r
| `query_money_supply_data_month()` | 货币供应量/月 |\r
| `query_money_supply_data_year()` | 货币供应量/年 |\r
\r
### 10. 板块数据\r
\r
| 函数 | 说明 |\r
|------|------|\r
| `query_stock_industry()` | 行业分类 |\r
| `query_sz50_stocks()` | 上证50成分股 |\r
| `query_hs300_stocks()` | 沪深300成分股 |\r
| `query_zz500_stocks()` | 中证500成分股 |\r
\r
## 股票代码规则\r
\r
- `sh.xxxxxx` - 上海证券交易所(6位数字)\r
- `sz.xxxxxx` - 深圳证券交易所(6位数字)\r
- `sh.000001` - 上证指数\r
- `sh.000300` - 沪深300指数\r
\r
## ⚠️ 股票筛选默认规则 (重要)\r
\r
> **"全市场扫描" = 全部A股股票 ,不包括沪深300/上证50/中证500等成分股**\r
> \r
> 除非特别指明"沪深300"、"上证50",否则默认都是全部A股\r
\r
| 字段 | 值 | 说明 |\r
|------|-----|------|\r
| `type` | `1` | 仅A股股票 (排除指数/ETF/可转债) |\r
| `status` | `1` | 仅上市状态 (排除退市/停牌) |\r
\r
```python\r
# 获取上市中的A股股票列表 (全市场)\r
rs = bs.query_stock_basic()\r
data = []\r
while rs.next():\r
data.append(rs.get_row_data())\r
df = pd.DataFrame(data, columns=rs.fields)\r
stocks = df[(df['type'] == '1') & (df['status'] == '1')]\r
# 约 5,191 只A股 (全市场)\r
\r
# 仅沪深300成分股 (需特别指明)\r
rs = bs.query_hs300_stocks()\r
```\r
\r
## ⚠️ 全市场扫描执行规则\r
\r
> 全市场扫描 (5,000+股票) 耗时长,**必须提示用户确认后再执行**\r
\r
### 执行流程\r
\r
1. **提示用户** → 显示扫描范围、预估时间\r
2. **等待确认** → 用户确认后才开始执行\r
3. **分批执行** → 每50只显示进度,避免被限流\r
4. **完成后汇总** → 输出结果列表\r
\r
### 提示语示例\r
\r
```\r
⚠️ 即将进行全市场扫描\r
- 扫描范围:全部A股股票\r
- 预估时间:约30-60分钟\r
- 扫描进行中,请稍候...\r
```\r
/\r
## 示例代码\r
\r
### 获取单只股票K线\r
\r
```python\r
import baostock as bs\r
import pandas as pd\r
\r
lg = bs.login()\r
\r
# 获取浦发银行日K线\r
rs = bs.query_history_k_data_plus(\r
"sh.600000",\r
"date,code,open,high,low,close,volume,amount,pctChg",\r
start_date='2024-01-01',\r
end_date='2024-12-31'\r
)\r
\r
data_list = []\r
while (rs.error_code == '0') & rs.next():\r
data_list.append(rs.get_row_data())\r
\r
df = pd.DataFrame(data_list, columns=rs.fields)\r
print(df)\r
\r
bs.logout()\r
```\r
\r
### 获取多只股票基本资料\r
\r
```python\r
import baostock as bs\r
\r
lg = bs.login()\r
\r
# 获取所有股票\r
rs = bs.query_stock_basic()\r
while rs.next():\r
print(rs.get_row_data())\r
\r
bs.logout()\r
```\r
\r
### 获取财务数据\r
\r
```python\r
import baostock as bs\r
\r
lg = bs.login()\r
\r
# 获取浦发银行2024年Q2盈利能力\r
rs = bs.query_profit_data(code="sh.600000", year=2024, quarter=2)\r
while rs.next():\r
print(rs.get_row_data())\r
\r
bs.logout()\r
```\r
\r
### 获取板块成分股\r
\r
```python\r
import baostock as bs\r
\r
lg = bs.login()\r
\r
# 获取上证50成分股\r
rs = bs.query_sz50_stocks()\r
while rs.next():\r
print(rs.get_row_data())\r
\r
bs.logout()\r
```\r
\r
## 注意事项\r
\r
1. **无需注册** - BaoStock 免费使用,无需注册\r
2. **数据范围** - 支持1990年至今的历史数据\r
3. **更新频率** - 日K线盘后更新\r
4. **复权说明** - 使用涨跌幅复权法,与同花顺/通达信可能有差异\r
5. **频率限制** - 请勿频繁请求,建议添加适当延时\r
\r
---\r
\r
## 技术分析 (MyTT 集成)\r
\r
> 本技能集成了 MyTT 技术分析库,当用户说"分析xxx的技术面"时,自动调用技术分析功能。\r
\r
### 使用方式\r
\r
| 用户输入 | 系统行为 |\r
|----------|----------|\r
| "分析中金黄金的技术面" | 调用 baostock + MyTT → 输出标准化技术分析报告 |\r
| "查询中金黄金的K线数据" | 仅调用 baostock → 输出原始K线数据(不经过MyTT) |\r
\r
### 标准分析报告格式\r
\r
当用户要求技术分析时,必须输出以下标准化格式:\r
\r
#### 1. 均线系统\r
- MA5, MA10, MA20, MA30, MA60\r
- 均线方向判断(↗上涨/↘下跌/→持平)\r
- 金叉/死叉/多头/空头信号\r
\r
#### 2. MACD 指标\r
- DIF, DEA, MACD 三个值\r
- 金叉/死叉判断\r
- 多头/空头判断\r
\r
#### 3. KDJ 指标\r
- K, D, J 三个值\r
- 超买/超卖判断(K>80超买,K\x3C20超卖)\r
- 金叉/死叉判断\r
\r
#### 4. RSI 指标\r
- RSI 值\r
- 强弱判断(>70超买,\x3C30超卖,50中性)\r
\r
#### 5. BOLL 布林带\r
- 上轨、中轨、下轨\r
- 股价位置判断(突破上轨/跌破下轨/在中轨附近)\r
\r
#### 6. 综合判断\r
- 短期评分 (1-5星)\r
- 中期评分 (1-5星)\r
- 操作建议\r
\r
### 技术分析脚本\r
\r
```bash\r
# 命令行使用\r
python3 scripts/technical_analysis.py sh.600489\r
\r
# 或指定其他股票\r
python3 scripts/technical_analysis.py sz.000001\r
```\r
\r
### 输出示例\r
\r
```\r
📈 中金黄金 (sh.600489) 技术分析报告\r
更新时间: 2026-03-14 22:13:42\r
============================================================\r
\r
【均线系统】\r
├── MA5: 31.47 元 (方向: ↘)\r
├── MA10: 32.17 元 (方向: ↘)\r
├── MA20: 31.39 元 (方向: ↗)\r
├── MA30: 32.28 元 (方向: ↗)\r
├── MA60: 28.35 元 (方向: ↗)\r
└── 信号: MA5\x3CMA10 死叉, MA20>MA60 多头\r
\r
【MACD指标】\r
├── DIF: 0.4310\r
├── DEA: 0.7290\r
└── MACD: -0.5960\r
信号: 空头 死叉\r
\r
【KDJ指标】\r
├── K: 24.53\r
├── D: 34.17\r
└── J: 5.26\r
信号: 死叉, 超卖\r
\r
【RSI指标】\r
├── RSI(6): 52.08\r
├── RSI(12): 52.08\r
└── RSI(24): 52.08\r
信号: 偏强\r
\r
【BOLL布林带】\r
├── 上轨: 33.93\r
├── 中轨: 31.39\r
└── 下轨: 28.84\r
信号: 在中轨附近\r
\r
【综合判断】\r
├── 短期: ⭐⭐ (2/5)\r
├── 中期: ⭐⭐⭐⭐ (4/5)\r
└── 建议: 中性震荡\r
\r
============================================================\r
数据来源: BaoStock + MyTT\r
```\r
\r
### 可用技术指标 (完整列表)\r
\r
本技能集成了以下 MyTT 指标函数:\r
\r
| 分类 | 指标 | 说明 |\r
|------|------|------|\r
| 趋势 | MACD | 指数平滑异同移动平均线 |\r
| 趋势 | DMI | 动向指标 |\r
| 趋势 | TRIX | 三重指数平滑平均线 |\r
| 趋势 | EXPMA | EMA指数平均数 |\r
| 趋势 | BBI | 多空指标 |\r
| 均线 | MA | 简单移动平均 |\r
| 均线 | EMA | 指数移动平均 |\r
| 均线 | SMA | 中国式SMA |\r
| 超买超卖 | KDJ | 随机指标 |\r
| 超买超卖 | RSI | 相对强弱指标 |\r
| 超买超卖 | WR | 威廉指标 |\r
| 超买超卖 | CCI |顺势指标 |\r
| 超买超卖 | ROC | 变动率指标 |\r
| 超买超卖 | MTM | 动量指标 |\r
| 通道 | BOLL | 布林带 |\r
| 通道 | KTN | 肯特纳交易通道 |\r
| 通道 | TAQ | 唐安奇通道 |\r
| 能量 | OBV | 能量潮 |\r
| 能量 | VR | 容量比率 |\r
| 能量 | MFI | 资金流量指标 |\r
| 能量 | ASI | 振动升降指标 |\r
| 能量 | EMV | 简易波动指标 |\r
| 形态 | BRAR | 情绪指标 |\r
| 形态 | PSY | 心理线 |\r
| 形态 | DPO | 区间震荡线 |\r
Usage Guidance
This skill appears to do what it claims: fetch A‑share market and financial data via the Baostock Python library and run local MyTT technical analysis. Before installing, note: (1) it will need network access to reach the Baostock service; (2) pip will install third‑party packages (baostock, pandas) — verify package sources if you require strict supply‑chain controls; (3) full‑market scans are expensive and the SKILL.md sensibly requires explicit user confirmation before running them; and (4) no credentials are requested by the skill itself. If you run this in a sensitive environment, restrict network access or review the upstream baostock package source on PyPI/GitHub first.
Capability Analysis
Type: OpenClaw Skill
Name: baostock-tt-skills
Version: 1.0.1
The skill bundle provides a legitimate interface for the BaoStock financial data platform and includes the MyTT technical analysis library. Analysis of the Python scripts (technical_analysis.py, MyTT.py) and instructions (SKILL.md) reveals no evidence of data exfiltration, malicious execution, or prompt injection; it even includes safety guidelines requiring user confirmation for long-running market scans.
Capability Assessment
Purpose & Capability
Name and description match the actual code and SKILL.md: the package uses baostock to fetch A-share market data and includes MyTT-based technical analysis. Required binaries (python3, pip) and Python package dependencies (baostock, pandas) are appropriate and proportionate.
Instruction Scope
SKILL.md instructs installing baostock and calling its APIs (login/query/logout) and documents a mandatory user confirmation for long "full-market" scans. The runtime instructions and example scripts only access market data via the baostock library and local analysis code, and do not read unrelated system files or environment secrets.
Install Mechanism
No custom install spec is provided; installation is standard via pip (pip install baostock). All included code is plain Python and the requirements.txt lists known packages. No arbitrary remote archive downloads or execution of code from untrusted servers are present.
Credentials
The skill declares no required environment variables or credentials. The code calls baostock.login() which is the expected API pattern for this service (BaoStock supports anonymous login). There are no requests for unrelated tokens, keys, or access to other config paths.
Persistence & Privilege
The skill is not always-enabled and does not request elevated or persistent privileges. It does not modify other skills or global agent configuration. Autonomous invocation is allowed (platform default) but that is normal for skills.
How to Use
- Make sure OpenClaw is installed (local or Docker)
- Run the install command in chat:
/install baostock-tt-skills - After installation, invoke the skill by name or use
/baostock-tt-skills - Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.1
- Added requirements.txt to specify Python dependencies.
- Removed install_prompt.md from the project.
- No user-facing behavior or feature changes; dependency management improved.
v1.0.0
Initial release of BaoStock 金融数据技能:
- 提供 A 股历史K线、财务、宏观经济、板块成分股等免费数据查询,无需注册
- 支持多种数据API,涵盖K线、财报、除权息、复权因子、行业与成分股等
- 集成 MyTT 技术分析库,智能输出标准化技术分析报告
- 强调全市场扫描需用户确认,避免批量操作误触
- 附详细参数说明、API调用示例与注意事项
Metadata
Frequently Asked Questions
What is baostock_tt_skills?
获取A股历史K线数据、季频财务数据、宏观经济数据、板块成分股等. It is an AI Agent Skill for Claude Code / OpenClaw, with 264 downloads so far.
How do I install baostock_tt_skills?
Run "/install baostock-tt-skills" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.
Is baostock_tt_skills free?
Yes, baostock_tt_skills is completely free, licensed under MIT-0. You can download, install and use it at no cost.
Which platforms does baostock_tt_skills support?
baostock_tt_skills is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).
Who created baostock_tt_skills?
It is built and maintained by jasonpro22 (@jasonpro22); the current version is v1.0.1.
More Skills