# 股票历史行情

> 查询股票历史行情数据

## 接口基本信息

- **接口名称**：`get_stock_history_quotation`
- **当前版本**：`v2`
- **功能描述**：获取股票历史日线行情数据，支持显式选择复权方式
- **数据更新频率**：日线
- **请求方法**：`POST`
- **API 路径**：`https://api.wanxingai.com/openapi/stock_history_quotation/`

---

## 使用示例

以下示例显式请求不复权日线：

```python
import requests

url = "https://api.wanxingai.com/openapi/stock_history_quotation/"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer sk-********"
}
payload = {
    "stock_code": "600519.SH",
    "indicators": "preClose,open,high,low,close,amount,volume,changeRatio",
    "startdate": "2025-01-01",
    "enddate": "2025-01-31",
    "adjustment": "none"
}

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 = """
    {"stock_code": "600519.SH",
     "indicators": "preClose,open,high,low,close,amount,volume,changeRatio",
     "startdate": "2025-01-01", "enddate": "2025-01-31",
     "adjustment": "none"}
    """;

HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.wanxingai.com/openapi/stock_history_quotation/"))
    .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/stock_history_quotation/ \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-********" \
  -d '{"stock_code":"600519.SH","indicators":"preClose,open,high,low,close,amount,volume,changeRatio","startdate":"2025-01-01","enddate":"2025-01-31","adjustment":"none"}'
```

## 输入参数说明

| 参数名 | 类型 | 必选 | 描述 | 示例 |
| --- | --- | --- | --- | --- |
| `stock_code` | string | **是** | 完整股票代码，需含交易所后缀；最多支持 10 个股票，以英文逗号分隔 | `600519.SH` |
| `indicators` | string | **是** | 指标列表，以英文逗号分隔 | `open,high,low,close` |
| `startdate` | string | **是** | 开始日期，格式 `YYYY-MM-DD` | `2025-01-01` |
| `enddate` | string | **是** | 结束日期，格式 `YYYY-MM-DD` | `2025-03-31` |
| `adjustment` | string | 否 | 复权方式；允许值见下表。未传时默认为 `forward_cash`，以兼容既有调用 | `none` |

### adjustment 允许值

| 参数值 | 含义 |
| --- | --- |
| `none` | 不复权 |
| `backward_cash` | 后复权（现金分红） |
| `forward_cash` | 前复权（现金分红） |
| `backward_reinvest` | 后复权（分红再投） |
| `forward_reinvest` | 前复权（分红再投） |

复权方式影响 `preClose`、`open`、`high`、`low`、`close` 等价格字段，不改变成交量。显式取得与不复权分钟行情相同价格口径的日线时，请传：

```json
{
  "stock_code": "600000.SH",
  "indicators": "preClose,open,high,low,close,volume",
  "startdate": "2026-06-18",
  "enddate": "2026-06-18",
  "adjustment": "none"
}
```

## 返回结构

成功时 HTTP 状态为 200，业务 `status=200`：

```json
{
  "status": 200,
  "message": [
    {
      "thscode": "600000.SH",
      "time": ["2026-06-18"],
      "table": {
        "preClose": [9.24],
        "open": [9.20],
        "high": [9.25],
        "low": [9.07],
        "close": [9.09],
        "volume": [83656385]
      }
    }
  ]
}
```

| 字段 | 类型 | 说明 |
| --- | --- | --- |
| `status` | integer | 业务状态码；成功为 200 |
| `message` | array | 股票行情结果列表 |
| `message[].thscode` | string | 股票代码 |
| `message[].time` | string[] | 交易日期数组 |
| `message[].table` | object | 按请求指标返回的数据列 |
| `message[].table.preClose` | float[] | 前收盘价，单位：元 |
| `message[].table.open` | float[] | 开盘价，单位：元 |
| `message[].table.high` | float[] | 最高价，单位：元 |
| `message[].table.low` | float[] | 最低价，单位：元 |
| `message[].table.close` | float[] | 收盘价，单位：元 |
| `message[].table.amount` | float[] | 成交额，单位：元 |
| `message[].table.volume` | integer[] | 成交量，单位：股 |
| `message[].table.changeRatio` | float[] | 涨跌幅，单位：% |
| `message[].table.turnoverRatio` | float[] | 换手率，单位：% |

## 支持的常用指标

| 指标名 | 中文含义 | 说明 |
| --- | --- | --- |
| `preClose` | 前收盘价 | 上一交易日收盘价 |
| `open` | 开盘价 | 当日开盘价格 |
| `high` | 最高价 | 当日最高成交价 |
| `low` | 最低价 | 当日最低成交价 |
| `close` | 收盘价 | 当日收盘价格；正式字段为 `close` |
| `amount` | 成交额 | 当日成交总金额，单位：元 |
| `volume` | 成交量 | 当日成交总量，单位：股 |
| `changeRatio` | 涨跌幅 | 相对前收盘价的涨跌幅，单位：% |
| `turnoverRatio` | 换手率 | 成交量占流通股本的比例，单位：% |

## 版本记录

### v2（2026-07-21）

- 新增可选参数 `adjustment`，支持不复权、现金分红前后复权、分红再投前后复权。
- 未传 `adjustment` 时保持既有默认口径：`forward_cash`。
- 明确日线收盘价正式请求指标和返回字段为 `close`。
- 明确日线 `volume` 单位为股。

---
