# 基金实时估值

> 查询基金实时估值

## 接口基本信息

- **接口名称**: `get_fund_realtime_valuation`
- **功能描述**: 获取基金实时估值（分钟频）。交易时段外返回空数组
- **数据更新频率**: 分钟级
- **请求方法**: `POST`
- **API 路径**: `https://api.wanxingai.com/openapi/get_fund_realtime_valuation/`

---

## 输入参数说明

| 参数名 | 类型 | 必选 | 默认值 | 描述 | 示例 |
| --- | --- | --- | --- | --- | --- |
| `fund_codes` | str | **是** | — | 基金代码，英文逗号分隔 | `110011.OF,000001.OF` |
| `outputpara` | str | **是** | — | 输出字段控制，格式 `"字段名:Y,字段名:Y"`，可用字段见下表 | `changeRatioValuation:Y,realTimeValuation:Y` |
| `only_latest` | str | 否 | `"1"` | `"1"`-仅返回最新估值；`"0"`-返回时间区间 | `1` |
| `begin_time` | str | 否 | `""` | 开始时间（only\_latest="0" 时必填），格式 YYYY-MM-DD HH:mm:ss | `2026-04-17 09:30:00` |
| `end_time` | str | 否 | `""` | 结束时间（only\_latest="0" 时必填），格式 YYYY-MM-DD HH:mm:ss | `2026-04-17 15:00:00` |

---

### outputpara 可用字段

| 字段名 | 中文含义 |
| --- | --- |
| `changeRatioValuation` | 估值涨跌幅（%） |
| `realTimeValuation` | 实时估值净值（元） |
| `Deviation30TDays` | 30个交易日均偏差率（%） |
| `rank` | 估值涨跌幅排名 |

---

### 返回数据说明

| 字段名 | 类型 | 描述 |
| --- | --- | --- |
| `fundcode` | str | 基金代码 |
| `time` | array[str] | 估值时间序列 |
| `table` | object | 估值数据对象（字段由 outputpara 决定） |

---

## 使用示例

```python
import requests

url = "https://api.wanxingai.com/openapi/get_fund_realtime_valuation/"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer sk-********"
}
# 查询最新估值
payload = {
    "fund_codes": "110011.OF",
    "outputpara": "changeRatioValuation:Y,realTimeValuation:Y,rank:Y",
    "only_latest": "1"
}

resp = requests.post(url, json=payload, headers=headers)
print(resp.json())

# 查询时间区间估值
payload2 = {
    "fund_codes": "110011.OF",
    "outputpara": "changeRatioValuation:Y,realTimeValuation:Y",
    "only_latest": "0",
    "begin_time": "2026-04-17 09:30:00",
    "end_time": "2026-04-17 15:00:00"
}
resp2 = requests.post(url, json=payload2, headers=headers)
print(resp2.json())
```

```java
import java.net.http.*;
import java.net.URI;

HttpClient client = HttpClient.newHttpClient();
String json = """
    {"fund_codes": "110011.OF", "outputpara": "changeRatioValuation:Y,realTimeValuation:Y,rank:Y", "only_latest": "1"}
    """;

HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.wanxingai.com/openapi/get_fund_realtime_valuation/"))
    .header("Content-Type", "application/json")
    .header("Authorization", "Bearer sk-********")
    .POST(HttpRequest.BodyPublishers.ofString(json))
    .build();

HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
```

```curl
curl -X POST https://api.wanxingai.com/openapi/get_fund_realtime_valuation/ \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-********" \
  -d '{"fund_codes": "110011.OF", "outputpara": "changeRatioValuation:Y,realTimeValuation:Y,rank:Y", "only_latest": "1"}'
```

### 注意事项

1. 非交易时段调用返回空数组 `[]`
2. 当 `only_latest="0"` 时，`begin_time` 和 `end_time` 为必填
