TopRank Skills

Official OpenClaw rules 36%

baostock

Free Chinese A-share stock data via BaoStock — K-lines, financials, industry classification, no registration required.

Stars

0

Installs

0

Status

ACTIVE

Visibility

PUBLIC

安装方式

直接复制以下提示词,发送给你的 AI 助手即可完成安装。

请先检查是否已安装 SkillHub 商店,若未安装,请根据 https://skillhub-1388575217.cos.ap-guangzhou.myqcloud.com/install/skillhub.md 安装 SkillHub 商店,然后安装 baostock 技能。 若已安装,则直接安装 baostock 技能。

Overview

Skill Key
coderwpf/baostock
Author
coderwpf
Source Repo
openclaw/skills
Version
1.0.0
Source Path
skills/coderwpf/baostock
Latest Commit SHA
2e3fc64044b15fa7c962553ff9696efbe5925822

Extracted Content

SKILL.md excerpt

# BaoStock (证券宝 — 免费A股数据平台)

[BaoStock](https://www.baostock.com) is a free, open-source securities data platform for Chinese A-shares. No registration or API key needed. Returns `pandas.DataFrame`.

## Install

```bash
pip install baostock --upgrade
```

Verify:

```bash
python3 -c "import baostock as bs; lg = bs.login(); print(lg.error_msg); bs.logout()"
```

Should print `login success!`.

## Usage pattern

Every session must call `bs.login()` before queries and `bs.logout()` when done:

```python
import baostock as bs
import pandas as pd

lg = bs.login()

# ... queries here ...

bs.logout()
```

Result sets use `.get_data()` to get a DataFrame:

```python
rs = bs.query_all_stock()
df = rs.get_data()
```

## Core APIs

### 1. query_all_stock — List all securities

Get all stock/index codes for a given trading date.

```python
rs = bs.query_all_stock(day="2024-01-02")
df = rs.get_data()
# columns: code, tradeStatus, code_name
```

- **day** — Date string `YYYY-MM-DD` (default: today). Non-trading days return empty DataFrame.

### 2. query_history_k_data_plus — K-line data

Get historical K-line data (OHLCV + indicators).

```python
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",
    adjustflag="3"
)
df = rs.get_data()
```

**Parameters:**

- **code** — Stock code, format `sh.600000` or `sz.000001`
- **fields** — Comma-separated field names (see below)
- **start_date** / **end_date** — `YYYY-MM-DD`
- **frequency** — `d` (daily), `w` (weekly), `m` (monthly), `5`/`15`/`30`/`60` (minute bars). Index has no minute data.
- **adjustflag** — `1` (forward adj), `2` (backward adj), `3` (no adj, default)

**Available fields (daily):**

`date`, `code`, `open`, `high`, `low`, `close`, `preclose`, `volume`, `amount`, `adjustflag`, `turn` (turnover rate), `tradestatus`, `pctChg` (change %), `peTTM`, `pbMRQ`, `psTTM`, `pcfNcfTTM`, `isS...

Related Claw Skills