Search

PythonReactSEOPDF
OpenClaw

baostock

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

coderwpf0 source installs☆ 0 Repository starsv1.0.0

Installation

Follow the repository instructions for this skill and your agent. Review the files and dependencies before adding it to your workflow.

SkillHub CLI

skillhub install coderwpf/baostock

Inspect the source and compatibility requirements, then follow its installation steps.

Give your agent the source link and ask it to inspect instructions and dependencies before explaining the installation steps.

View source ↗Guides

Skill instructions

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

BaoStock is a free, open-source securities data platform for Chinese A-shares. No registration or API key needed. Returns pandas.DataFrame.

Install

pip install baostock --upgrade

Verify:

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:

import baostock as bs
import pandas as pd

lg = bs.login()

# ... queries here ...

bs.logout()

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

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.

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).

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...

Source information

Source
github
Repository
openclaw/skills
Path
skills/coderwpf/baostock
Version
1.0.0
Commit
2e3fc64044b15fa7c962553ff9696efbe5925822
Classification source
rules
Status
active
Visibility
public

These signals come from indexed source analysis and may lag behind changes. Check the current source files.

Extracted content

SKILL.md
# 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 skills

OpenClaw

a-stock-trader

bombfuock

A股模拟交易系统 - 数据爬取、存储、策略回测、模拟交易 / A-Share Paper Trading System - Data Fetch, Storage, Backtest, Simulation

OpenClaw

adaptive-skill-factory

505768069-rgb

Discover, install, update, or create the right skill when a workflow gap appears. Use when a task is repetitive, a role lacks a reliable procedure, an existing skill might save time, ClawHub search/install coul...