| name | baostock | ||||||
|---|---|---|---|---|---|---|---|
| description | BaoStock A-share securities data API reference — 23 endpoints covering K-line, financials, macro, dividends, and industry classification with 9 documented pitfalls and pandas 2.0+ compatibility fixes | ||||||
| version | 1.0.0 | ||||||
| author | atompilot | ||||||
| tags |
|
This playbook provides Claude / OpenClaw with complete knowledge of the BaoStock Python API for China A-share securities data.
- User asks to fetch A-share stock data using BaoStock
- Writing data pipelines that consume BaoStock APIs
- Debugging BaoStock code (pandas 2.0+ crashes, string type issues, etc.)
- Looking up BaoStock API parameters, fields, or return formats
See the full skill file at skills/baostock/SKILL.md for complete API documentation including:
- 23 APIs across 5 categories (Market Data, Basic Info, Dividends, Quarterly Financial, Macroeconomic)
- 9 documented pitfalls (pandas 2.0+ compatibility, stdout pollution, string types, etc.)
- Complete field reference for every API endpoint
- Code examples with correct patterns
import baostock as bs
import pandas as pd
import os, contextlib
# Suppress stdout pollution
with open(os.devnull, "w") as devnull:
with contextlib.redirect_stdout(devnull):
bs.login()
# Query data
rs = bs.query_history_k_data_plus(
"sh.600000",
"date,code,open,high,low,close,volume,amount",
start_date="2024-01-01",
end_date="2024-12-31",
frequency="d",
adjustflag="3",
)
# Collect results (pandas 2.0+ compatible — DO NOT use rs.get_data())
rows = []
while (rs.error_code == "0") and rs.next():
rows.append(rs.get_row_data())
df = pd.DataFrame(rows, columns=rs.fields)
# Convert string columns to numeric
for col in ["open", "high", "low", "close", "volume", "amount"]:
df[col] = pd.to_numeric(df[col], errors="coerce")
bs.logout()