# 基金份额

- 接口：get_fund_share
- 路径：/api/v1/market/data/fund/fund-share
- 方法：GET
- 描述：按基金代码分页查询基金份额变动。`stati_perd` 选统计周期（日/季度/年度/截止时点/半年/全部，默认全部），`start_date`/`end_date` 按响应的 `trade_date` 过滤。返回期末份额、期初份额、申购份额、赎回份额、份额净变动、份额变动率；份额字段单位为「份」，不做万份换算。返回分页结构（items/total_pages/total_items）。
- 数据范围：按基金代码与统计周期查询
- 单次限量：默认 `page=1`/`page_size=50`；上限 200
- 提示：
  - `fund_code` 必填。
  - `stati_perd` 枚举：`日`/`季度`/`年度`/`截止时点`/`半年`/`全部`，其余报错，默认 `全部`。
  - `start_date` ≤ `end_date`，日期过滤作用于响应的 `trade_date`。
  - `截止时点` 周期仅返回期末份额，期初/申购/赎回/变动字段为空。

## 输入参数

| 名称 | 类型 | 必选 | 描述 |
|------|------|------|------|
| fund_code | string | Y | 基金代码 |
| stati_perd | string | N | 统计周期：日/季度/年度/截止时点/半年/全部，默认全部 |
| start_date | integer | N | 开始日期 YYYYMMDD（按 trade_date 过滤） |
| end_date | integer | N | 结束日期 YYYYMMDD |
| page | integer | N | 页码，默认 1 |
| page_size | integer | N | 每页条数，默认 50，上限 200 |

所有输入参数均通过 GET query string 传递。

## 输出参数
成功响应外层固定为 `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 数组：

| 名称 | 类型 | 默认显示 | 描述 |
|------|------|---------|------|
| fund_code | string | Y | 基金代码 |
| fund_name | string | Y | 基金名称 |
| trade_code | string | Y | 交易代码 |
| 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/v1/market/data/fund/fund-share?fund_code=000001&stati_perd=年度&page=1&page_size=5"
curl -sS "https://market.ft.tech/gateway/api/v1/market/data/fund/fund-share?fund_code=000001&stati_perd=全部&page=1&page_size=5"
```

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

```python
import ftshare as ft

market = ft.market_api()

# 查询指定基金的年度份额数据
rows = market.fund_share(fund_code="000001", stati_perd="年度")
print(rows)

# 限制返回条数，SDK 自动翻页
rows = market.fund_share(fund_code="000001", stati_perd="全部", limit=10)

# 返回原始 JSON
payload = market.fund_share(fund_code="000001", stati_perd="年度", raw=True)
```

## 数据样例

`fund_code=000001&stati_perd=全部`（华夏成长混合A），节选核心列（fund_code/fund_name/trade_code 列省略）：

| statistics_period | trade_date | fund_share | begin_shares | purchase_shares | redemption_shares | shares_change | shares_change_ratio |
|-------------------|------------|------------|--------------|-----------------|-------------------|---------------|---------------------|
| 季度 | 20260331 | 2592338348.96 | 2711854516.99 | 124739864.35 | 244256032.38 | -119516168.03 | -4.4072 |
| 截止时点 | 20260331 | 2592338348.96 |  |  |  |  |  |
| 年度 | 20251231 | 2711854516.99 | 3057101216.68 | 331507303.19 | 676754002.88 | -345246699.69 | -11.2933 |
