# ETF成分证券明细

- 接口：etf_component_details
- 路径：/api/v2/market/data/etf-component-details
- 方法：GET
- 描述：按 ETF 和交易日返回申赎清单中的全部成分证券及数量。`symbol` 必填；不传 `trade_date` 时返回该 ETF 最新可用交易日的数据。
- 数据范围：20250501 至今。
- 单次限量：无分页，一次返回单只 ETF 的全部成分证券。
- 提示：
  - `trade_date` 为精确查询条件。该日期没有数据时成功返回空数组，不向前回退。
  - 现金占位成分会保留，并将 `component_type` 标记为 `cash`。
  - `component_type` 可能为 `stock`、`bond`、`commodity` 或 `cash`；无法确定时返回 `null`。
  - `cash_substitution_flag` 为原始标志值，`cash_substitution_type` 提供对应的通用分类。
  - 本接口不返回成分权重。

## 输入参数


| 名称       | 类型    | 必选 | 描述                                                    |
| ---------- | ------- | ---- | ------------------------------------------------------- |
| symbol     | string  | Y    | ETF 代码，如`510300.SH`、`159915.SZ`                    |
| trade_date | integer | N    | 交易日，格式`YYYYMMDD`；不传时查询该 ETF 最新可用交易日 |

## 输出参数

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

| 名称    | 类型         | 默认显示 | 描述                                                                         |
| ------- | ------------ | -------- | ---------------------------------------------------------------------------- |
| code    | integer      | Y        | 业务状态码，与 HTTP 状态码一致：`200` 成功 / `400` 参数错误 / `500` 服务错误 |
| message | string       | Y        | 成功固定为`success`；失败时为中文错误信息                                    |
| data    | array / null | Y        | 成功时为 ETF 成分证券明细数组；失败时为`null`                                |

data 数组：


| 名称                           | 类型           | 默认显示 | 描述                                                                            |
| ------------------------------ | -------------- | -------- | ------------------------------------------------------------------------------- |
| symbol                         | string         | Y        | ETF 代码                                                                        |
| trade_date                     | integer        | Y        | 实际返回的交易日，格式`YYYYMMDD`                                                |
| component_code                 | string         | Y        | 成分证券代码；已知市场使用`.SH`、`.SZ`、`.BJ` 或 `.HK` 后缀                     |
| component_name                 | string         | Y        | 成分证券名称                                                                    |
| component_type                 | string / null  | Y        | `stock`、`bond`、`commodity` 或 `cash`；无法识别时为 `null`                     |
| quantity                       | integer / null | Y        | 成分证券数量，单位为股；源数据缺失时为`null`                                    |
| cash_substitution_flag         | integer / null | Y        | 现金替代原始编码；源数据缺失时为`null`                                          |
| cash_substitution_type         | string / null  | Y        | 归一类型：`prohibited`、`allowed`、`mandatory` 或 `refund`；未知编码时为 `null` |
| creation_substitution_amount   | number / null  | Y        | 申购替代金额                                                                    |
| redemption_substitution_amount | number / null  | Y        | 赎回替代金额                                                                    |
| general_substitution_amount    | number / null  | Y        | 通用替代金额                                                                    |

现金替代编码解释：


| cash_substitution_flag | cash_substitution_type | 说明         |
| ---------------------- | ---------------------- | ------------ |
| 0                      | prohibited             | 禁止现金替代 |
| 1                      | allowed                | 允许现金替代 |
| 2、4、6、8             | mandatory              | 必须现金替代 |
| 3、5、7                | refund                 | 退补现金替代 |

不同交易所的现金替代编码语义可能存在差异；需要精确区分时应以 `cash_substitution_flag` 为准。

## 接口示例

```bash
# 查询 ETF 最新可用成分明细
curl -sS "https://market.ft.tech/gateway/api/v2/market/data/etf-component-details?symbol=510300.SH"

# 查询指定交易日
curl -sS "https://market.ft.tech/gateway/api/v2/market/data/etf-component-details?symbol=510300.SH&trade_date=20260908"
```

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

```python
import ftshare as ft

market = ft.market_api()

# 查询最新可用交易日的全部成分证券，默认返回 DataFrame
df = market.etf_component_details(symbol="510300.SH")
print(df[["component_code", "component_name", "component_type", "quantity"]].head(3))
#   component_code component_name component_type  quantity
# 0       600000.SH         浦发银行          stock      2100
# ...

# 指定交易日查询
df2 = market.etf_component_details(symbol="510300.SH", trade_date="20260908")

# 返回原始 JSON
payload = market.etf_component_details(symbol="510300.SH", raw=True)
```

## 数据样例

`symbol=510300.SH` 最新交易日 20260910（节选）：

| symbol | trade_date | component_code | component_name | component_type | quantity | cash_substitution_flag | cash_substitution_type | creation_substitution_amount | redemption_substitution_amount | general_substitution_amount |
|--------|------------|----------------|----------------|----------------|----------|------------------------|------------------------|------------------------------|--------------------------------|-----------------------------|
| 510300.SH | 20260910 | 600000.SH | 浦发银行 | stock | 2100 | 1 | allowed | null | null | null |
| 510300.SH | 20260910 | 600009.SH | 上海机场 | stock | 200 | 1 | allowed | null | null | null |
| 510300.SH | 20260910 | 600010.SH | 包钢股份 | stock | 3600 | 1 | allowed | null | null | null |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
