# 指数两融指标

> 查询指数两融指标数据

## 接口基本信息

- **接口名称**: `get_index_margin_trading`
- **功能描述**: 查询指数两融指标数据（融资买入额、融资偿还额、融资余额、融券卖出量）
- **数据更新频率**: 日频
- **请求方法**: `POST`
- **API 路径**: `https://api.wanxingai.com/openapi/get_index_margin_trading/`

---

## 输入参数说明

| 参数名 | 类型 | 必选 | 默认值 | 描述 | 示例 |
| --- | --- | --- | --- | --- | --- |
| `index_code` | str | **是** | — | 指数代码，需含交易所后缀 | `000001.SH` |
| `datestr` | str | 否 | 今天 | 查询日期，格式 YYYY-MM-DD，不传则默认今天 | `2026-04-01` |

---

### 返回数据说明

| 字段名 | 类型 | 描述 |
| --- | --- | --- |
| `code` | str | 指数代码 |
| `data` | array | 指标数组 |
| `margin_trading_sell_amt_index` | float | 融资买入额 |
| `margin_trading_repay_amt_index` | float | 融资偿还额 |
| `margin_trading_balance_index` | float | 融资余额 |
| `short_selling_sell_vol_index` | float | 融券卖出量 |

---

## 使用示例

```python
import requests

url = "https://api.wanxingai.com/openapi/get_index_margin_trading/"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer sk-********"
}
payload = {"index_code": "000001.SH", "datestr": "2026-04-01"}

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

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

HttpClient client = HttpClient.newHttpClient();
String json = """
    {"index_code": "000001.SH", "datestr": "2026-04-01"}
    """;

HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.wanxingai.com/openapi/get_index_margin_trading/"))
    .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_index_margin_trading/ \\
  -H "Content-Type: application/json" \\
  -H "Authorization: Bearer sk-********" \\
  -d '{"index_code": "000001.SH", "datestr": "2026-04-01"}'
```

### 注意事项

1. datestr 不传则默认使用今天日期
2. 融资余额反映市场杠杆资金规模
