# 基金持仓明细

- 接口：get_fund_portfolio
- 路径：/api/v1/market/data/fund/fund-portfolio
- 方法：GET
- 描述：按 `fund_code` 查基金报告期持仓明细。`report_date` 单期或 `start_date`/`end_date` 区间（互斥），`publish_date` 按发布日期过滤。未传日期默认返回最新一期。返回分页结构（items/total_pages/total_items），含发布/报告期、报告类型、资产类型及分组、持仓代码/名称/序号/数量/市值/占净值比等 14 个字段。
- 数据范围：按报告期查询
- 单次限量：默认 `page=1`/`page_size=50`；上限 200
- 提示：
  - `fund_code` 必填。
  - `report_date` 与 `start_date`+`end_date` 互斥。
  - `start_date` 与 `end_date` 必须同时传入，且 `start_date` ≤ `end_date`。
  - 未传日期默认最新一期。
  - `trade_code` 对部分标的（债券/转债）可能为空。

## 输入参数

| 名称 | 类型 | 必选 | 描述 |
|------|------|------|------|
| fund_code | string | Y | 基金代码 |
| report_date | integer | N | 报告期 YYYYMMDD（与 start/end 互斥） |
| publish_date | integer | N | 发布日期 YYYYMMDD |
| start_date | integer | N | 报告期起始日期（需与 end_date 同传） |
| end_date | integer | N | 报告期结束日期 |
| 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 | 交易代码（部分债券/转债可能为空） |
| publish_date | integer | Y | 发布日期 YYYYMMDD |
| report_date | integer | Y | 报告期 YYYYMMDD |
| report_type | string | Y | 报告类型 |
| asset_type | string | Y | 资产类型 |
| asset_type_group | string | Y | 资产类型分组 |
| holding_code | string | Y | 持仓代码 |
| holding_name | string | Y | 持仓名称 |
| holding_order | integer | Y | 持仓序号 |
| holding_shares | string | Y | 持仓数量 |
| market_value | string | Y | 持仓市值 |
| net_value_ratio | string | Y | 占基金净值比例（%） |

## 接口示例

```bash
curl -sS "https://market.ft.tech/gateway/api/v1/market/data/fund/fund-portfolio?fund_code=000001&page=1&page_size=5"
curl -sS "https://market.ft.tech/gateway/api/v1/market/data/fund/fund-portfolio?fund_code=000001&report_date=20260331&page=1&page_size=5"
```

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

```python
import ftshare as ft

market = ft.market_api()

# 查询最新一期持仓，限制返回条数
rows = market.fund_portfolio(fund_code="000001", limit=10)
print(rows)

# 查询指定报告期
rows = market.fund_portfolio(fund_code="000001", report_date=20260331, limit=10)

# 按报告期区间查询
rows = market.fund_portfolio(
    fund_code="000001", start_date=20250101, end_date=20260331, limit=10
)

# 返回原始 JSON
payload = market.fund_portfolio(fund_code="000001", report_date=20260331, raw=True)
```

## 数据样例

`fund_code=000001`（华夏成长混合A 一季报 20260331），节选核心列（fund_code/fund_name/trade_code/publish_date/report_date/report_type/asset_type_group/holding_order 列省略）：

| asset_type | holding_code | holding_name | holding_shares | market_value | net_value_ratio |
|------------|--------------|--------------|----------------|--------------|-----------------|
| 转股期可转债 | 113696 | 伯25转债 | 102040 | 13534591.19 | 0.51 |
| 债券 | 19827 | 26国债01 | 632000 | 63366865.32 | 2.4 |
| 股票 | 300308 | 中际旭创 | 200000 | 113882000 | 4.31 |
| 转股期可转债 | 127084 | 柳工转2 | 75200 | 10759348.16 | 0.41 |
| ... | ... | ... | ... | ... | ... |
