# 百度财经日历

- 接口：baidu_financial_calendar
- 路径：/api/v1/market/data/finance/financial-calendar/baidu
- 方法：GET
- 描述：查询百度财经日历，按日期范围返回经济数据、新股 IPO、财报披露时间和交易提醒四类财经事件。可通过 `category` 筛选单一类别，不传时返回全部类别。响应为分页结构，`records` 中每条记录通过 `category` 标识类别，各类字段均直接位于记录中。结果按事件日期、时间和标题或代码升序排列。数据来源：百度。
- 数据范围：按日期范围查询，起止日期之差不超过 3 天
- 单次限量：分页返回，`page_size` 默认 50、最大 200；`page` 默认 1
- 提示：
  - `start_date` / `end_date` 必填，格式为 `YYYYMMDD`，起止日期之差不得超过 3 天，否则返回 `code=400`。
  - `category` 可选，取值为 `economic` / `ipo` / `report_time` / `trade_reminder`；非法值返回 `code=400`。
  - 数据来源：百度（路径中保留 `baidu` 来源标识）。
  - `records` 中每条记录带有 `category` 标签；各类别字段不同，不适用的字段不会出现或返回 `null`。

## 输入参数

| 名称 | 类型 | 必选 | 描述 |
|------|------|------|------|
| start_date | string | Y | 起始日期，格式为 `YYYYMMDD` |
| end_date | string | Y | 结束日期，格式为 `YYYYMMDD`，与 `start_date` 之差不超过 3 天 |
| category | string | N | 筛选大类：`economic` / `ipo` / `report_time` / `trade_reminder`；不传返回全部 |
| page | integer | N | 页码，从 1 开始，默认 1 |
| page_size | integer | N | 每页条数，默认 50，最大 200 |

## 输出参数

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

| 名称 | 类型 | 默认显示 | 描述 |
|------|------|---------|------|
| code | integer | Y | 状态码：成功为 200；参数或日期范围错误为 400 |
| message | string | Y | 状态信息 |
| data | object / null | Y | 成功时为分页对象；失败时为 `null` |

### data 对象：

| 名称 | 类型 | 默认显示 | 描述 |
|------|------|---------|------|
| pageNum | integer | Y | 当前页码 |
| pageSize | integer | Y | 每页条数 |
| total | integer | Y | 总记录数 |
| pages | integer | Y | 总页数 |
| records | array | Y | 财经日历条目（带 category 标签） |

### records 数组：

| 名称 | 类型 | 默认显示 | 描述 |
|------|------|---------|------|
| category | string | Y | 大类标签：`economic`/`ipo`/`report_time`/`trade_reminder` |
| stat_date | string | Y | 事件日期 |
| region | string | N | 地区（economic 类） |
| time | string / null | N | 事件时间 |
| title | string | N | 事件标题（economic 类） |
| former_val | string / null | N | 前值（economic 类） |
| market_value | string / null | N | 市场预期值 |
| pub_val | string / null | N | 公布值（economic 类） |
| indicate_val | string / null | N | 指标值（economic 类） |
| star | string / null | N | 重要性星级（economic 类） |
| negative | string / null | N | 利空方向（economic 类） |
| positive | string / null | N | 利多方向（economic 类） |
| capitalization | string / null | N | 市值或规模信息 |
| code | string | N | 标的代码（ipo/report_time/trade_reminder 类） |
| name | string | N | 标的名称（ipo/report_time/trade_reminder 类） |
| exchange | string / null | N | 交易所 |
| market | string / null | N | 市场 |
| sub_tab | string / null | N | 子分类（ipo/trade_reminder 类） |
| price | string / null | N | 价格（ipo 类） |
| volume | string / null | N | 发行量（ipo 类） |
| amount | string / null | N | 募集金额（ipo 类） |
| unit | string / null | N | 单位（ipo 类） |
| pe_ratio | string / null | N | 市盈率（ipo 类） |
| date_range | string / null | N | 日期区间（ipo 类） |
| max_volume | string / null | N | 最大发行量（ipo 类） |
| report_type | string / null | N | 报告类型（report_time 类） |
| market_time | string / null | N | 上市或披露时间（report_time 类） |
| meeting_type | string / null | N | 会议类型（trade_reminder 类） |
| reason | string / null | N | 提醒原因（trade_reminder 类） |
| divi_cash | string / null | N | 分红金额（trade_reminder 类） |
| divi_date | string / null | N | 分红日期（trade_reminder 类） |
| transfer | string / null | N | 转送信息（trade_reminder 类） |
| start_date | string / null | N | 起始日期（trade_reminder 类） |
| end_date | string / null | N | 结束日期（trade_reminder 类） |
| type | string / null | N | 子类型（ipo/report_time/trade_reminder 类） |

> 注：上表为四类记录字段的并集。每条记录仅返回其 `category` 对应的字段；不适用的字段不会出现，可选字段缺失时可能返回 `null`。

## 接口示例

```bash
curl -sS "https://market.ft.tech/gateway/api/v1/market/data/finance/financial-calendar/baidu?start_date=20260617&end_date=20260619&category=economic&page=1&page_size=50"
```

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

```python
import ftshare as ft

market = ft.market_api()

# start_date/end_date 必填且间隔 ≤ 3 天；不传 category 返回全部大类
df = market.baidu_financial_calendar(start_date="20260624", end_date="20260626", page=1, page_size=10)
print(df.head())

# category 筛选单一类别；limit 为 SDK 参数，用于限制合并返回的记录数
df = market.baidu_financial_calendar(start_date="20260624", end_date="20260626", category="economic", limit=20)

# 返回原始 JSON 信封（未经 DataFrame 抽取）
payload = market.baidu_financial_calendar(start_date="20260624", end_date="20260626", raw=True)
```

## 数据样例

响应外层为 `code`、`message`、`data`，`data.records` 中的记录通过 `category` 区分类别。以下为字段结构示例：

| category | stat_date | region | time | title |
|----------|-----------|--------|------|-------|
| economic | YYYY-MM-DD | 地区 | HH:MM | 经济指标名称 |

> 注：`category` 支持 `economic`、`ipo`、`report_time`、`trade_reminder`；各类别的字段不同。
