# 股本

- 接口：get_stock_share
- 路径：/api/v2/market/data/share/get-stock-share
- 方法：GET
- 描述：查询股票股本信息。`date` 在所有查询模式下均为必填；传入 `stock_code` 时，返回该标的截至指定日期的最新股本记录；不传 `stock_code` 时，返回指定日期所有股本记录并分页。日期条件可按发布日期 `publish_date` 或生效日期 `end_date` 查询，默认按发布日期查询。返回总股本、A 股流通/限售/无限售股本、B 股股本（流通/非流通）、H 股股本、境外上市股本、流通股本合计，以及发布日期和生效日期。
- 数据范围：按发布日期或生效日期查询
- 单次限量：全市场查询单页最多 500 条；单标的查询最多 1 条
- 提示：
  - `date` 必填，格式 YYYYMMDD；即使传入 `stock_code`，也不能省略 `date`。
  - `stock_code` 选填；不传时查询全市场。
  - `date_type` 可选，允许值为 `publish_date` 或 `end_date`，默认值为 `publish_date`。
  - 不传 `stock_code` 时使用 `page` 和 `page_size` 分页，`page` 默认 1，`page_size` 默认 200，最大 500。
  - 未命中数据时 `items` 为空数组。
  - 金额/股数字段以字符串返回，保持精度。
  - 缺少 `date` 时返回 HTTP 400。

## 输入参数

| 名称 | 类型 | 必选 | 描述 |
|------|------|------|------|
| stock_code | string | N | 股票代码。支持六位数字、短交易所后缀（如 `600000.SH`）和长后缀（如 `600000.XSHG`） |
| date | string | Y | 日期 YYYYMMDD |
| date_type | string | N | 日期条件类型：`publish_date`（发布日期，默认）或 `end_date`（生效日期） |
| page | integer | N | 全市场查询页码，从 1 开始，默认 1；单标的查询时忽略 |
| page_size | integer | N | 全市场查询每页条数，默认 200，取值范围 1-500；单标的查询时忽略 |

## 输出参数
成功响应外层固定为 `code`、`message`、`data`：

| 名称 | 类型 | 默认显示 | 描述 |
|------|------|---------|------|
| code | integer | Y | HTTP 状态码；成功固定为 200 |
| message | string | Y | 成功固定为 `success`；失败时为中文错误信息 |
| data | object / null | Y | 成功时为业务数据对象；失败时为 `null`。其字段如下 |


data 对象：

| 名称 | 类型 | 默认显示 | 描述 |
|------|------|---------|------|
| items | array | Y | 股本信息列表 |
| total_pages | integer | Y | 总页数 |
| total_items | integer | Y | 总记录数 |

items 数组：

| 名称 | 类型 | 默认显示 | 描述 |
|------|------|---------|------|
| stock_code | string | Y | 股票代码 |
| stock_name | string | Y | 股票名称 |
| publish_date | integer | Y | 发布日期，格式 YYYYMMDD |
| end_date | integer | Y | 生效日期，格式 YYYYMMDD |
| totshare_num | string | Y | 总股本 |
| ashare_circ_num | string | Y | A 股流通股本 |
| ashare_circ_limit_num | string | Y | A 股限售流通股本 |
| ashare_circ_unlimit_num | string | Y | A 股无限售流通股本 |
| bshare_num | string | Y | B 股股本 |
| bshare_circ_num | string | Y | B 股流通股本 |
| bshare_uncirc_num | string | Y | B 股非流通股本 |
| hshare_num | string | Y | H 股股本 |
| osshare_num | string | Y | 境外上市股本 |
| share_circ_num | string | Y | 流通股本合计 |

## 接口示例

```bash
curl -sS "https://market.ft.tech/gateway/api/v2/market/data/share/get-stock-share?stock_code=000001.SZ&date=20260716"

# 按生效日期查询单只股票
curl -sS "https://market.ft.tech/gateway/api/v2/market/data/share/get-stock-share?stock_code=920476.BJ&date=20261012&date_type=end_date"

# 不传股票代码，查询指定发布日期的全市场股本信息
curl -sS "https://market.ft.tech/gateway/api/v2/market/data/share/get-stock-share?date=20261012&date_type=publish_date&page=1&page_size=5"
```

Python（[`ftshare`](https://github.com/FTShare-Lab/FTShare-python-sdk.git) SDK，方法 `market.stock_share`，默认返回 pandas `DataFrame`）：

```python
import ftshare as ft

market = ft.market_api()

# 查询单只股票指定日期的股本信息
rows = market.stock_share(stock_code="000001.SZ", date="20260716")
print(rows)

# 返回原始 JSON
payload = market.stock_share(stock_code="000001.SZ", date="20260716", raw=True)
```

## 数据样例

`stock_code=920476.BJ&date=20261012&date_type=end_date`：

| stock_code | stock_name | publish_date | end_date | totshare_num | ashare_circ_num | ashare_circ_limit_num | ashare_circ_unlimit_num | bshare_num | bshare_circ_num | bshare_uncirc_num | hshare_num | osshare_num | share_circ_num |
|------------|------------|--------------|----------|--------------|-----------------|-----------------------|-------------------------|-----------|-----------------|------------------|------------|-------------|----------------|
| 920476.BJ | 海能技术 | 20260930 | 20261012 | 89585740 | 89585740 | 8958382 | 80627358 | 0 | 0 | 0 | 0 | 0 | 89585740 |
