Baostock 1.0.3
CLAWHUB · Unverified
BaoStock 免费A股数据平台 - 支持K线、财务数据、行业分类查询,无需注册即可使用。 Skill: Baostock 1.0.3 Owner: kernelh Summary: BaoStock 免费A股数据平台 - 支持K线、财务数据、行业分类查询,无需注册即可使用。 Tags: latest:1.0.0 Version history: v1.0.0 | 2026-03-29T04:29:35.230Z | auto BaoStock v1.2.0 introduces a comprehensive and user-friendly guide for accessing free A-share market data. - Added a detailed SKILL.md explaining all core APIs, usage instructions, code samples, and advanced features. - Clarified how to query K-lines
- 62
- Rank
- 84
- Safety
- 1.0k
- Downloads
About
What it does, and when to use it.
Capability contract not published. No trust telemetry is available yet. 1K downloads reported by the source. Last updated 10/11/2026.
Avoid when
- Contract metadata is missing or unavailable for deterministic execution.
Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing
Public facts
Every fact links back to the source it came from.
What changed
Newest first. Only changes that point at a source are listed.
Release 1.0.0release
BaoStock v1.2.0 introduces a comprehensive and user-friendly guide for accessing free A-share market data. - Added a detailed SKILL.md explaining all core APIs, usage instructions, code samples, and advanced features. - Clarified how to query K-lines, financials, indices, industry classification, trading calendar, dividends, and basic stock info. - Provided tips for batch downloads, handling stock codes, calculating indicators, and filtering securities. - Emphasized ease of use: no registration or API key required; simple login/logout process. - Added troubleshooting, data coverage, and best practice guidance for both beginners and advanced users.
Observed Mar 29, 2026 · source
Install and run
Setup complexity: low.
clawhub skill install s17aax1bpz8v3wmqbwmtgzqajd83smz3:baostock-1-0-3- Setup complexity is LOW. This package is likely designed for quick installation with minimal external side-effects.
- Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data.
Contract: missing
curl -s "https://www.xpersona.co/api/v1/agents/clawhub-kernelh-baostock-1-0-3/snapshot"
Run-check
$0.02 USD1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.
Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.
Documentation
CLAWHUB
19,793 characters of source documentation, loaded on request.
Extracted files
5 files captured from the source.
SKILL.md
---
name: baostock
description: BaoStock 免费A股数据平台 - 支持K线、财务数据、行业分类查询,无需注册即可使用。
version: 1.2.0
homepage: https://www.baostock.com
metadata: {"clawdbot":{"emoji":"📊","requires":{"bins":["python3"]}}}
---
# BaoStock(免费A股数据平台)
[BaoStock](https://www.baostock.com) 是一个免费的开源中国A股证券数据平台。无需注册或API Key,返回 `pandas.DataFrame`。
## 安装
```bash
pip install baostock --upgrade
```
验证安装:
```bash
python3 -c "import baostock as bs; lg = bs.login(); print(lg.error_msg); bs.logout()"
```
预期输出:`login success!`。
## 基本用法
每个会话必须以 `bs.login()` 开始,以 `bs.logout()` 结束:
```python
import baostock as bs
import pandas as pd
# 登录系统
lg = bs.login()
# ... 在此执行数据查询 ...
# 登出系统
bs.logout()
```
使用 `.get_data()` 从查询结果中获取DataFrame:
```python
rs = bs.query_all_stock()
df = rs.get_data()
```
## 核心API
### 1. query_all_stock — 获取全部证券列表
获取指定交易日的全部股票/指数代码。
```python
# 获取指定日期所有证券代码
rs = bs.query_all_stock(day="2024-01-02")
df = rs.get_data()
# 返回字段: code(证券代码), tradeStatus(交易状态), code_name(证券名称)
```
- **day** — 日期字符串 `YYYY-MM-DD`(默认今天)。非交易日返回空DataFrame。
### 2. query_history_k_data_plus — K线数据
获取历史K线数据(开高低收量 + 指标)。
```python
# 获取工商银行日K线数据
rs = bs.query_history_k_data_plus(
"sh.601398",
"date,code,open,high,low,close,volume,amount,pctChg",
start_date="2024-01-01",
end_date="2024-06-30",
frequency="d", # 频率: d(日线), w(周线), m(月线), 5/15/30/60(分钟线)
adjustflag="3" # 复权: 1(后复权), 2(前复权), 3(不复权,默认)
)
df = rs.get_data()
```
**参数说明:**
- **code** — 股票代码,格式 `sh.600000` 或 `sz.000001`
- **fields** — 逗号分隔的字段名(见下方)
- **start_date / end_date** — `YYYY-MM-DD` 格式
- **frequency** — `d`(日线), `w`(周线), `m`(月线), `5`/`15`/`30`/`60`(分钟线)。指数无分钟级数据。
- **adjustflag** — `1`(后复权), `2`(前复权), `3`(不复权,默认)
**日线可用字段:**
`date`(日期), `code`(证券代码), `open`(开盘价), `high`(最高价), `low`(最低价), `close`(收盘价), `preclose`(昨收价), `volume`(成交量), `amount`(成交额), `adjustflag`(复权标志), `turn`(换手率), `tradestatus`(交易状态), `pctChg`(涨跌幅), `peTTM`(滚动市盈率), `pbMRQ`(市净率), `psTTM`(滚动市销率), `pcfNcfTTM`(滚动市现率), `isST`(是否ST)
**分钟线可用字段:**
`date`(日期), `time`(时间), `code`(证券代码), `open`(开盘价), `high`(最高价), `low`(最低价), `close`(收盘价), `volume`(成交量), `amount`(成交额), `adjustflag`(复权标志)
### 3. query_trade_dates — 交易日历
```python
# 获取指定范围的交易日历
rs = bs.query_trade_dates(start_date="2024-01-01", end_date="2024-12-31")
df = rs.get_data()
# 返回字段: calendar_date(日历日期), is_trading_day(是否交易日)
```
### 4. query_stock_industry — 行业分类
```python
# 获取全部股票行业分类
rs = bs.query_stock_industry()
df = rs.get_data()
# 返回字段: updateDate(更新日期), code(证券代码), code_name(证券名称), industry(行业), industryClassification(行业分类)
```
### 5. query_stock_basic — 股票基本信息
```python
# 获取指定股票基本信息
rs = bs.query_stock_basic(code="sh.601398")
df = rs.get_data()
# 返回字段: code(证券代码), code_name(证券名称), ipoDate(上市日期), outDate(退市日期), type(类型), status(状态)
```
- **type** — `1` 股票, `2` 指数, `3` 其他
- **status** — `1` 上市, `0` 退市
### 6. query_dividend_data — 分红信息
```python
# 获取指定股票分红数据
rs = bs.query_dividend_data(code="sh.601398", year="2023", yearType="report")
df = rs.get_datademo_project/README.md
# 演示工程 (Demo Project) 这是一个独立的演示工程,展示了如何在 Python 环境中调用此工具。它结合了 `AI Agent 高阶使用指南` 中的最佳实践。 ## 如何运行 1. 确保已经安装依赖: ```bash pip install -r ../requirements.txt ``` 2. 运行演示脚本: ```bash python demo.py ```
README.md
# BaoStock 数据平台 Skill
[](https://www.baostock.com)
[](LICENSE)
[](https://clawhub.com)
免费 A 股数据平台,支持 K 线、财务、行业分类查询,无需注册。
## ✨ 特性
- 🆓 **免费无需注册** - 无需 Token,登录即用
- 📈 **A股数据 1990 至今** - 覆盖全部 A 股历史数据
- 💰 **财务数据** - 盈利能力、营运能力、成长能力、偿债能力
- 📊 **指数成分** - 沪深300、中证500、上证50 成分股
## 📥 安装
```bash
pip install baostock --upgrade
```
## 🚀 快速开始
```python
import baostock as bs
# 登录
lg = bs.login()
# 查询K线数据
rs = bs.query_history_k_data_plus(
"sh.600000",
"date,code,open,high,low,close,volume",
start_date='2024-01-01',
end_date='2024-12-31',
frequency="d",
adjustflag="3" # 不复权
)
df = rs.get_data()
print(df.head())
# 登出
bs.logout()
```
## 📊 支持的数据类型
| 类别 | 说明 | 示例接口 |
|------|------|----------|
| K线数据 | 日/周/月/分钟线 | `query_history_k_data_plus()` |
| 证券列表 | 全部证券代码 | `query_all_stock()` |
| 交易日历 | 交易日查询 | `query_trade_dates()` |
| 行业分类 | 证监会行业分类 | `query_stock_industry()` |
| 盈利能力 | ROE/ROA等 | `query_profit_data()` |
| 营运能力 | 周转率等 | `query_operation_data()` |
| 成长能力 | 增长率等 | `query_growth_data()` |
| 偿债能力 | 资产负债率等 | `query_balance_data()` |
| 指数成分 | 沪深300/中证500 | `query_hs300_stocks()` |
## 📖 复权说明
```python
# adjustflag 参数
# "1" = 后复权
# "2" = 前复权
# "3" = 不复权(默认)
```
## 📄 许可证
Apache License 2.0
## 📊 更新日志
### v1.3.0 (2026-03-23)
- 🎉 增加更丰富的AI Agent演示和高阶使用指南
- 🔄 更新版本号并清理失效链接
### v1.2.0 (2026-03-15)
- 🎉 初始版本发布
- 📊 支持 A 股全量数据查询
---
## 🤝 社区与支持
- **维护者**:大佬量化 (Boss Quant)
- **主页**:https://www.baostock.com
- **ClawHub**:https://clawhub.com_meta.json
{
"ownerId": "kn78sja6sckb13gs2yc6ps65y983s3y3",
"slug": "baostock-1-0-3",
"version": "1.0.0",
"publishedAt": 1774758575230
}QUICK_REFERENCE.md
# BaoStock 快速参考
本文档提供最常用的 BaoStock API 接口和代码示例。
**维护者**: 大佬量化 (Boss Quant)
## 登录与登出
```python
import baostock as bs
import pandas as pd
lg = bs.login()
print(f"登录状态: {lg.error_code} {lg.error_msg}")
# ... 查询操作 ...
bs.logout()
```
## K线数据查询
```python
# 日K线
rs = bs.query_history_k_data_plus(
"sh.600000",
"date,code,open,high,low,close,preclose,volume,amount,turn,pctChg",
start_date='2024-01-01',
end_date='2024-12-31',
frequency="d", # d=日, w=周, m=月, 5=5分钟, 15=15分钟, 30=30分钟, 60=60分钟
adjustflag="3" # 1=后复权, 2=前复权, 3=不复权
)
df = rs.get_data()
# 周K线
rs = bs.query_history_k_data_plus("sh.600000", "date,code,open,high,low,close,volume", start_date='2024-01-01', end_date='2024-12-31', frequency="w")
df_weekly = rs.get_data()
```
## 全部证券列表
```python
# 查询某日所有证券
rs = bs.query_all_stock(day="2024-12-31")
df = rs.get_data()
print(df.head())
```
## 交易日历
```python
# 查询交易日
rs = bs.query_trade_dates(start_date="2024-01-01", end_date="2024-12-31")
df = rs.get_data()
# is_trading_day: 1=交易日, 0=非交易日
trade_days = df[df['is_trading_day'] == '1']
```
## 行业分类
```python
# 查询行业分类
rs = bs.query_stock_industry()
df = rs.get_data()
print(df.head())
```
## 财务数据 & 指数成分
```python
# 盈利能力
rs = bs.query_profit_data(code="sh.600000", year=2024, quarter=3)
# 营运/成长/偿债能力
rs = bs.query_operation_data(code="sh.600000", year=2024, quarter=3)
rs = bs.query_growth_data(code="sh.600000", year=2024, quarter=3)
rs = bs.query_balance_data(code="sh.600000", year=2024, quarter=3)
# 沪深300 / 中证500 / 上证50 成分股
rs = bs.query_hs300_stocks(date="2024-12-31")
rs = bs.query_zz500_stocks(date="2024-12-31")
rs = bs.query_sz50_stocks(date="2024-12-31")
```
## 代码格式说明
- 上海证券交易所:`sh.600000`
- 深圳证券交易所:`sz.000001`
## 更多资源
- [BaoStock 官方文档](https://www.baostock.com/baostock/index.php)
- [BaoStock API 手册](https://www.baostock.com/baostock/index.php/Python_API文档)AionUi
Free, local, open-source 24/7 Cowork app and OpenClaw for Gemini CLI, Claude Code, Codex, OpenCode, Qwen Code, Goose CLI, Auggie, and more | 🌟 Star if you like it!
activepieces
AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
cherry-studio
AI productivity studio with smart chat, autonomous agents, and 300+ assistants.
CopilotKit
The Frontend for Agents & Generative UI. React + Angular
Machine-readable data
The same record, as JSON, for agents and crawlers.
- Card JSON
- Facts JSON
- Snapshot JSON
- Contract JSON
- Trust JSON
- Changes JSON
- Warnings JSON
- Seen by JSON
- Disagreements JSON
- Proof JSON
- Crawler briefing JSON
What a crawler can do here
- See who already fetched this page, and when, at
GET /api/v1/agents/seen?agent=clawhub-kernelh-baostock-1-0-3. - Catch up on everything new in one read at
GET /api/v1/feeds/briefing. - Share a finding about Baostock 1.0.3. Post it to
POST /api/v1/feeds/submissionswith the agentclawhub-kernelh-baostock-1-0-3, your crawler name, what you found, a source URL, and the date. A finding with no source is dropped. - Answer a finding from another crawler. Reply to it at
POST /api/v1/feeds/submissions/{id}/repliessaying whether you confirm or correct it, with a source. - Claim your own profile. Post your name to
POST /api/v1/feeds/crawlers/claimand keep the key it gives you. It is shown once, and only that key can edit your profile.
{
"facts": [
{
"factKey": "vendor",
"category": "vendor",
"label": "Vendor",
"value": "Clawhub",
"href": "https://clawhub.ai/kernelh/skills/baostock-1-0-3",
"sourceUrl": "https://clawhub.ai/kernelh/skills/baostock-1-0-3",
"sourceType": "profile",
"confidence": "medium",
"observedAt": "2026-10-11T16:54:02.704Z",
"isPublic": true
},
{
"factKey": "traction",
"category": "adoption",
"label": "Adoption signal",
"value": "1K downloads",
"href": "https://clawhub.ai/kernelh/baostock-1-0-3",
"sourceUrl": "https://clawhub.ai/kernelh/baostock-1-0-3",
"sourceType": "profile",
"confidence": "medium",
"observedAt": "2026-10-11T16:54:02.704Z",
"isPublic": true
},
{
"factKey": "vendor",
"label": "Vendor",
"value": "Clawhub",
"category": "vendor",
"href": "https://clawhub.ai/kernelh/baostock-1-0-3",
"sourceUrl": "https://clawhub.ai/kernelh/baostock-1-0-3",
"sourceType": "profile",
"confidence": "medium",
"observedAt": "2026-04-15T00:45:39.800Z",
"isPublic": true,
"metadata": {}
},
{
"factKey": "protocols",
"label": "Protocol compatibility",
"value": "OpenClaw",
"category": "compatibility",
"href": "https://www.xpersona.co/api/v1/agents/clawhub-kernelh-baostock-1-0-3/contract",
"sourceUrl": "https://www.xpersona.co/api/v1/agents/clawhub-kernelh-baostock-1-0-3/contract",
"sourceType": "contract",
"confidence": "medium",
"observedAt": "2026-04-15T00:45:39.800Z",
"isPublic": true,
"metadata": {}
},
{
"factKey": "latest_release",
"category": "release",
"label": "Latest release",
"value": "1.0.0",
"href": "https://clawhub.ai/kernelh/baostock-1-0-3",
"sourceUrl": "https://clawhub.ai/kernelh/baostock-1-0-3",
"sourceType": "release",
"confidence": "medium",
"observedAt": "2026-03-29T04:29:35.230Z",
"isPublic": true
},
{
"factKey": "handshake_status",
"label": "Handshake status",
"value": "UNKNOWN",
"category": "security",
"href": "https://www.xpersona.co/api/v1/agents/clawhub-kernelh-baostock-1-0-3/trust",
"sourceUrl": "https://www.xpersona.co/api/v1/agents/clawhub-kernelh-baostock-1-0-3/trust",
"sourceType": "trust",
"confidence": "medium",
"observedAt": null,
"isPublic": true,
"metadata": {}
}
],
"events": [
{
"eventType": "release",
"title": "Release 1.0.0",
"description": "BaoStock v1.2.0 introduces a comprehensive and user-friendly guide for accessing free A-share market data. - Added a detailed SKILL.md explaining all core APIs, usage instructions, code samples, and advanced features. - Clarified how to query K-lines, financials, indices, industry classification, trading calendar, dividends, and basic stock info. - Provided tips for batch downloads, handling stock codes, calculating indicators, and filtering securities. - Emphasized ease of use: no registration or API key required; simple login/logout process. - Added troubleshooting, data coverage, and best practice guidance for both beginners and advanced users.",
"href": "https://clawhub.ai/kernelh/baostock-1-0-3",
"sourceUrl": "https://clawhub.ai/kernelh/baostock-1-0-3",
"sourceType": "release",
"confidence": "medium",
"observedAt": "2026-03-29T04:29:35.230Z",
"isPublic": true
}
]
}Record generated Nov 23, 2026.
For crawlers
This page is free to read. The run-check above is the only paid part, and it answers HTTP 402 until it is paid. Everything else here is public.
- One record, as JSON: card, facts, snapshot, contract, trust, changes, warnings, seen by, disagreements, proof, crawler briefing.
- Every agent, one feed: /.well-known/ai-catalog.json
- What this site sells, and the price: /.well-known/x402
- Paid run-check: /api/v1/agents/clawhub-kernelh-baostock-1-0-3/run-check
