# ETF份额

- 接口：etf_share
- 路径：/api/v2/market/data/etf-share
- 方法：GET
- 描述：按 ETF 代码分页查询份额变动，返回统计周期、统计日期、期末份额、期初份额、申购份额、赎回份额、份额净变动和份额变动率。支持按统计周期和日期范围筛选。
- 数据范围：按 ETF 代码和统计日期查询；实际可查询日期以接口返回为准
- 单次限量：默认 `page=1`、`page_size=50`，`page_size` 最大为 200
- 提示：
  - `etf_code` 必填，可传 ETF 代码，如 `510300`；兼容参数名 `fund_code`，建议使用 `etf_code`。
  - `stati_perd` 支持 `日`、`季度`、`年度`、`截止时点`、`半年`、`全部`，不传或传空字符串时默认为 `全部`。
  - `start_date` 和 `end_date` 可单独提供；同时提供时 `start_date` 不得晚于 `end_date`。
  - 日期格式为 YYYYMMDD，日期筛选作用于响应的 `trade_date`。
  - 份额字段（如 `fund_share`、`begin_shares`、`shares_change` 等）单位为份；这些数值字段以字符串形式返回，以保留小数精度。

## 输入参数

| 名称 | 类型 | 必选 | 描述 |
|------|------|------|------|
| etf_code | string | Y | ETF 代码，如 `510300`；兼容参数名 `fund_code` |
| stati_perd | string | N | 统计周期：`日`、`季度`、`年度`、`截止时点`、`半年`、`全部`，默认 `全部` |
| start_date | integer | N | 开始日期 YYYYMMDD，按 `trade_date` 过滤 |
| end_date | integer | N | 结束日期 YYYYMMDD，按 `trade_date` 过滤 |
| page | integer | N | 页码，从 1 开始，默认 1 |
| page_size | integer | N | 每页条数，默认 50，最大 200 |

## 输出参数

成功响应外层固定为 `code`、`message`、`data`：

| 名称 | 类型 | 默认显示 | 描述 |
|------|------|---------|------|
| code | integer | Y | HTTP 状态码；成功固定为 200 |
| message | string | Y | 成功固定为 `success`；失败时为错误信息 |
| data | object / null | Y | 成功时为分页数据对象；失败时为 `null` |

data 对象：

| 名称 | 类型 | 默认显示 | 描述 |
|------|------|---------|------|
| items | array | Y | ETF 份额变动列表 |
| total_pages | integer | Y | 总页数 |
| total_items | integer | Y | 总记录数 |

items 数组：

| 名称 | 类型 | 默认显示 | 描述 |
|------|------|---------|------|
| trade_code | string | Y | ETF 交易代码 |
| statistics_period | string | Y | 统计周期 |
| trade_date | integer | Y | 统计日期 YYYYMMDD |
| fund_share | string | Y | 期末份额，单位份 |
| begin_shares | string / null | N | 期初份额，单位份；无值时为 `null` |
| purchase_shares | string / null | N | 申购份额，单位份；无值时为 `null` |
| redemption_shares | string / null | N | 赎回份额，单位份；无值时为 `null` |
| shares_change | string / null | N | 份额净变动，单位份；无值时为 `null` |
| shares_change_ratio | string / null | N | 份额变动率，单位 %；无值时为 `null` |

## 接口示例

查询全部统计周期：

```bash
curl -sS "https://market.ft.tech/gateway/api/v2/market/data/etf-share?etf_code=510300&stati_perd=%E5%85%A8%E9%83%A8&page=1&page_size=5"
```

按日期范围查询：

```bash
curl -sS "https://market.ft.tech/gateway/api/v2/market/data/etf-share?etf_code=510300&start_date=20250101&end_date=20260909&page=1&page_size=5"
```

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

```python
import ftshare as ft

market = ft.market_api()

# 查询全部统计周期，默认返回 DataFrame
df = market.etf_share(etf_code="510300", stati_perd="全部", page=1, page_size=5)
print(df[["trade_code", "statistics_period", "trade_date", "fund_share"]].head(3))
#   trade_code statistics_period  trade_date     fund_share
# 0   510300.OF                日    20260909  23185387700
# ...

# 返回原始 JSON
payload = market.etf_share(etf_code="510300", stati_perd="全部", page=1, page_size=5, raw=True)
```

## 数据样例

`etf_code=510300&stati_perd=全部`（节选）：

| trade_code | statistics_period | trade_date | fund_share | begin_shares | purchase_shares | redemption_shares | shares_change | shares_change_ratio |
|------------|-------------------|------------|------------|--------------|-----------------|-------------------|---------------|---------------------|
| 510300.OF | 日 | 20260909 | 23185387700 | null | null | null | null | null |
| 510300.OF | 日 | 20260908 | 23468887700 | null | null | null | null | null |
| 510300.OF | 日 | 20260907 | 23648887700 | null | null | null | null | null |
| 510300.OF | 日 | 20260904 | 23377087700 | null | null | null | null | null |
| ... | ... | ... | ... | ... | ... | ... | ... | ... |
