lzwme/baostock
BaoStock 免费开源 A 股数据平台,无需注册、无需 API Key,支持股票行情、K线、财务数据、行业分类、指数成分股查询。当用户提及 baostock、需要获取A股历史行情、财务报表、交易日历,或需要**免费、免注册**的A股数据时使用。与 tushare(数据更全但需注册)和 jqdatasdk(聚宽数据)不同,baostock 完全免费无限制,适合快速入门和低成本数据需求。
npx skills add https://github.com/lzwme/finance-quant-skills --skill baostock
BAOSTOCK_SERVER_IP:自定义服务器 IP(用于 nginx 代理等场景)BAOSTOCK_SERVER_PORT:服务器端口,默认 10030python scripts/market_data.py --type kline --code sh.600000 --start 2024-01-01 --end 2024-01-31python scripts/financial_data.py --type profit --code sh.600000 --year 2023 --quarter 4python scripts/stock_info.py --type all_stocks --date 2024-01-02python scripts/stock_info.py --type index_stocks --index hs300python scripts/stock_info.py --type industrypython scripts/stock_info.py --type trade_dates --start 2024-01-01 --end 2024-12-31--file 指定代码列表文件--frequency 参数(d/w/m/5/15/30/60)--adjust 参数(1=后复权,2=前复权,3=不复权)python scripts/market_data.py --type kline --code sh.600519 --start 2024-03-01 --end 2024-03-31 --frequency d --adjust 2python scripts/financial_data.py --type profit --code sh.601398 --year 2023 --quarter 4python scripts/stock_info.py --type index_stocks --index hs300python scripts/market_data.py --type kline --code sh.600519,sz.000001,sh.600036 --start 2024-01-01 --end 2024-12-31 --output stocks.csvimport baostock as bs
import pandas as pd
# 登录系统
lg = bs.login()
# 获取日K线数据
rs = bs.query_history_k_data_plus(
"sh.600519",
"date,code,open,high,low,close,volume,amount",
start_date='2024-01-01', end_date='2024-12-31',
frequency="d", adjustflag="2"
)
# 转换为 DataFrame
data_list = []
while (rs.error_code == '0') & rs.next():
data_list.append(rs.get_row_data())
df = pd.DataFrame(data_list, columns=rs.fields)
# 登出系统
bs.logout()
| 特性 | baostock | tushare | jqdatasdk | akshare |
|------|----------|---------|-----------|---------|
| 费用 | 免费 | 免费/付费 | 需注册积分 | 免费 |
| 注册要求 | ❌ 不需要 | ✅ 需要 | ✅ 需要 | ❌ 不需要 |
| 数据范围 | A股为主 | 全面(含宏观) | A股+因子 | 全面(含加密货币) |
| K线数据 | ✅ | ✅ | ✅ | ✅ |
| 财务数据 | ✅ | ✅ | ✅ | ✅ |
| 分钟线 | ✅ | ✅ | ✅ | ✅ |
| 实时行情 | ❌ | ❌ | ❌ | ✅ |
| 特色数据 | 交易日历 | 宏观/Shibor | 因子数据 | 龙虎榜/北向/加密货币 |
bs.login() 即可使用sh.600000(上海)、sz.000001(深圳)、bj.430047(北京)bs.login() 开始、bs.logout() 结束.astype(float) 转换Take lzwme/baostock from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.