# 指数跟踪基金

- 接口：get_fund_index_fund
- 路径：/api/v2/market/data/fund/index-fund
- 方法：GET
- 描述：按指数代码查询跟踪该指数的基金，默认返回全市场（场内 ETF + 场外联接基金），`scope=etf` 仅返回场内 ETF。`index_code` 支持裸码或带后缀。直接返回数组（无分页包装），按 `fund_code` 升序；无匹配返回空数组。
- 数据范围：最新快照，无时间维度
- 单次限量：无分页，一次返回跟踪该指数的全量基金
- 提示：
  - `index_code` 必填，支持裸码（如 `000300`）或带后缀（如 `000300.SH`、`H30198.CSI`），后端取 `.` 之前的部分（即裸码）。
  - `scope` 取 `all`（默认，全市场）/ `etf`（仅场内 ETF，仅保留代码后缀为 `.SH`/`.SZ` 的场内基金），其余报错。

## 输入参数

| 名称 | 类型 | 必选 | 描述 |
|------|------|------|------|
| index_code | string | Y | 指数代码，支持裸码或带后缀 |
| scope | string | N | `all` 全市场（默认）/ `etf` 仅场内 ETF |


## 输出参数

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

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


data 数组：

| 名称 | 类型 | 默认显示 | 描述 |
|------|------|---------|------|
| fund_code | string | Y | 基金代码（带 .OF/.SH/.SZ 后缀） |
| name | string | Y | 基金简称 |
| fullname | string | Y | 基金全称 |
| index_code | string | Y | 跟踪指数代码 |
| index_name | string | Y | 跟踪指数名称 |
| index_type | string | Y | 指数类型 |

## 接口示例

```bash
curl -sS "https://market.ft.tech/gateway/api/v2/market/data/fund/index-fund?index_code=000300.SH"
curl -sS "https://market.ft.tech/gateway/api/v2/market/data/fund/index-fund?index_code=000300&scope=etf"
```

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

```python
import ftshare as ft

market = ft.market_api()

# 查询跟踪指定指数的全部基金
rows = market.fund_index_fund(index_code="000300.SH")
print(rows)

# 仅查询场内 ETF
rows = market.fund_index_fund(index_code="000300", scope="etf")

# 返回原始 JSON 数组
payload = market.fund_index_fund(index_code="000300.SH", raw=True)
```

## 数据样例

`index_code=000300.SH`（跟踪沪深300，total=85），节选核心列（fullname 列省略）：

| fund_code | name | index_code | index_name | index_type |
|------|------|------|------|------|
| 000051.OF | 华夏沪深300ETF联接A | 000300 | 沪深300指数 | 宽基指数 |
| 000613.OF | 国寿安保沪深300ETF联接A | 000300 | 沪深300指数 | 宽基指数 |
| 000961.OF | 天弘沪深300ETF联接A | 000300 | 沪深300指数 | 宽基指数 |
| 002987.OF | 广发沪深300ETF联接C | 000300 | 沪深300指数 | 宽基指数 |
| ... | ... | ... | ... | ... |
