# 股权质押明细

- 接口：stock_pledge_detail
- 路径：/api/v1/market/data/pledge/pledge-detail
- 方法：GET
- 描述：股权质押个股详细，返回每只股票的报告日期、质押比例、质押笔数、质押市值、质押无限售股数、质押限售股数、较上年变动等。支持两种模式：① 指定 `stock_code` 查询单只股票的质押历史；② 不传 `stock_code` 且 `is_last=true` 返回所有股票最新一期的质押数据。响应使用统一 `code/message/data` 壳，`data` 为包含 `items/total_items/total_pages` 的分页对象。
- 数据范围：按报告期查询
- 单次限量：分页返回，默认 `page=1`、`page_size=50`
- 提示：
  - 不传 `stock_code` 时必须 `is_last=true`，否则报错「请提供 stock_code 或设置 is_last=true」。
  - `trade_code` 统一为 `symbol.suffix` 格式（如 `600001.SH`）。
  - 金额/股数字段序列化为字符串（保留精度）。

## 输入参数

| 名称 | 类型 | 必选 | 描述 |
|------|------|------|------|
| stock_code | string | N | 股票代码（symbol.suffix 格式或纯代码）；不传时需配合 `is_last=true` |
| is_last | string | N | 是否仅获取最新一期（无 `stock_code` 时必填为 true） |
| page | integer | N | 页码，默认 1 |
| page_size | integer | N | 每页条数，默认 50 |

## 输出参数

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

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


data 对象：

| 名称 | 类型 | 默认显示 | 描述 |
|------|------|---------|------|
| items | array | Y | 个股质押明细列表 |
| total_pages | integer | Y | 总页数 |
| total_items | integer | Y | 总记录数（未分页前） |

items 数组：

| 名称 | 类型 | 默认显示 | 描述 |
|------|------|---------|------|
| trade_code | string | Y | 股票代码，如 `600001.SH` |
| stock_name | string | Y | 股票名称 |
| report_date | string | Y | 报告日期 |
| pledge_ratio | string | Y | 质押比例（%） |
| pledge_n | integer | Y | 质押笔数 |
| pledge_market_value | string | Y | 质押市值（元） |
| pledge_unlimitn | string | Y | 质押无限售股数 |
| pledge_limitn | string | Y | 质押限售股数 |
| last_year_fluctuation | string | N | 较上年变动（%） |

## 接口示例

```bash
curl -sS "https://market.ft.tech/gateway/api/v1/market/data/pledge/pledge-detail?stock_code=000001&page=1&page_size=10"
```

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

```python
import ftshare as ft

market = ft.market_api()

# 默认返回 DataFrame（全市场最新一期，无 stock_code 时 is_last 必须为 true）
df = market.stock_pledge_detail(is_last=True, page=1, page_size=5)
print(df[["trade_code", "stock_name", "report_date", "pledge_ratio", "pledge_n", "pledge_market_value"]])
#    trade_code stock_name report_date  pledge_ratio  pledge_n  pledge_market_value
# 0  000001.SZ     平安银行  2026-06-18          0.13         9            258844600
# 1  000004.SZ      国华退  2026-06-18          3.06         3             11174688
# 2  000007.SZ      全新好  2026-06-18          3.14         1            148838400

# limit 跨页取数（SDK 自动翻页拼成 20 行）
df = market.stock_pledge_detail(is_last=True, limit=20)

# 返回 list（每行一个 dict，as_dataframe=False）
rows = market.stock_pledge_detail(is_last=True, page=1, page_size=2, as_dataframe=False)
# rows == [{"trade_code": "000001.SZ", "stock_name": "平安银行", "pledge_ratio": "0.13", "pledge_n": 9, ...}]
```

## 数据样例

| trade_code | stock_name | report_date | pledge_ratio | pledge_n | pledge_market_value | pledge_unlimitn | pledge_limitn | last_year_fluctuation |
|------|------|------|------|------|------|------|------|------|
| 000001.SZ | 平安银行 | 2026-08-28 | 0.13 | 9 | 284082920 | 2438.48 | 0 | null |
| 000007.SZ | 全新好 | 2026-08-28 | 3.14 | 1 | 137088000 | 1088 | 0 | null |
| 000009.SZ | 中国宝安 | 2026-08-28 | 9.63 | 4 | 1802658000 | 24830 | 0 | null |
| 000010.SZ | *ST美丽 | 2026-08-28 | 11.27 | 7 | 207316480 | 4435.68 | 8521.6 | null |
| 000017.SZ | 深中华A | 2026-08-28 | 14.41 | 1 | 727174615 | 6350.87 | 0 | null |
