# 基金收益

- 接口：get_fund_cal_return
- 路径：/api/v1/market/data/fund/fund-cal-return
- 方法：GET
- 描述：按基金代码 + 区间类型查询基金累计收益率序列。校验 `fund_code` 与 `cal_type` 非空，根据区间类型（1M/3M/6M/1Y/3Y/5Y/YTD）取复权单位净值序列计算累计收益率，返回数组（非分页）。
- 数据范围：按交易日查询
- 单次限量：数组返回，条数由区间类型决定（1M≈20+ 交易日，YTD≈当年交易日数）
- 提示：
  - `fund_code`、`cal_type` 均必填。
  - `cal_type` 取值：`1M` / `3M` / `6M` / `1Y` / `3Y` / `5Y` / `YTD`。
  - 收益率字段在 JSON 中序列化为 `return`。

## 输入参数

| 名称 | 类型 | 必选 | 描述 |
|------|------|------|------|
| fund_code | string | Y | 基金代码（6位数字） |
| cal-type | string | Y | 查询区间：1M / 3M / 6M / 1Y / 3Y / 5Y / YTD（请求字段名为 `cal-type`） |


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

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


data 数组：

| 名称 | 类型 | 默认显示 | 描述 |
|------|------|---------|------|
| date | integer | Y | 日期 YYYYMMDD |
| return | number | Y | 累计收益率（JSON 字段名 `return`） |

## 接口示例

```bash
curl -sS "https://market.ft.tech/gateway/api/v1/market/data/fund/fund-cal-return?fund_code=110011&cal-type=1M"
```

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

```python
import ftshare as ft

market = ft.market_api()

# fund_code 必填；cal_type 必填（1M/3M/6M/1Y/3Y/5Y/YTD）
df = market.fund_cal_return(fund_code="110011", cal_type="1M")
print(df.shape)  # (21, 2)
print(df.head())
#        date  return
# 0  20260522  0.0000
# 1  20260525  0.0016
# 2  20260526 -0.0085

# 其它区间
df = market.fund_cal_return(fund_code="110022", cal_type="1Y")  # (238, 2)

# 返回原始 JSON（未经 DataFrame 抽取，列表结构）
payload = market.fund_cal_return(fund_code="110011", cal_type="1M", raw=True)
# payload == [{"date": 20260522, "return": 0.0}, {"date": 20260525, "return": 0.0016}, ...]
```

## 数据样例

| date | return |
|------|------|
| 20260803 | 0.0 |
| 20260804 | -0.0078 |
| 20260805 | -0.0114 |
| 20260806 | -0.0198 |
| 20260810 | -0.0036 |
