# 基金风险等级

- 接口：get_fund_risk_level
- 路径：/api/v1/market/data/fund/fund-risk-level
- 方法：GET
- 描述：查询基金风险等级。`fund_code` 必填，`history=true` 返回全部变更历史，缺省/`false` 仅当前有效。直接返回数组（非分页），含风险等级、数据来源、生效日、失效日、有效标记等 6 个字段。
- 数据范围：按变更日查询
- 单次限量：非分页，返回风险等级变更序列
- 提示：
  - `fund_code` 必填（trade_code 形式，纯数字按 `.OF` 解析）。
  - `history=true` 返回全部变更历史，否则仅当前有效。
  - 非分页，直接返回数组。
  - `risk_level` 取值 `低`/`中低`/`中`/`中高`/`高`（对应适当性 R1–R5）。

## 输入参数

| 名称 | 类型 | 必选 | 描述 |
|------|------|------|------|
| fund_code | string | Y | 基金代码 |
| history | string | N | true 返回全部变更历史，缺省/false 仅当前有效 |


## 输出参数
成功响应外层固定为 `code`、`message`、`data`：

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


data 数组：

| 名称 | 类型 | 默认显示 | 描述 |
|------|------|---------|------|
| fund_code | string | Y | 基金代码 |
| risk_level | string | Y | 风险等级（低/中低/中/中高/高） |
| data_source | string | Y | 来源（基金公司/基金公告） |
| begin_date | integer | Y | 生效日 YYYYMMDD |
| end_date | integer | N | 失效日 YYYYMMDD（当前有效为空） |
| is_valid | string | Y | 有效标记：1 有效 / 0 已失效 |

## 接口示例

```bash
curl -sS "https://market.ft.tech/gateway/api/v1/market/data/fund/fund-risk-level?fund_code=000001"
curl -sS "https://market.ft.tech/gateway/api/v1/market/data/fund/fund-risk-level?fund_code=000001&history=true"
```

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

```python
import ftshare as ft

market = ft.market_api()

# 查询当前有效的风险等级
rows = market.fund_risk_level(fund_code="000001")
print(rows)

# 查询全部风险等级变更历史
rows = market.fund_risk_level(fund_code="000001", history=True)

# 返回原始 JSON 数组
payload = market.fund_risk_level(fund_code="000001", history=True, raw=True)
```

## 数据样例

`fund_code=000001&history=true`（华夏成长混合A，total=2）：

| risk_level | data_source | begin_date | end_date | is_valid |
|------------|-------------|------------|----------|----------|
| 中高 | 基金公告 | 20260101 |  | 1 |
| 中 | 基金公司 | 20011218 | 20260101 | 0 |
