# K 线

`WS` `request · cmd 19`

> **行情权限要求 · 免费**
> 按账户等级配额，每自然月可查询 100–3,000 个标的（每月重置，详见文档中的配额表）。
> 美股：默认免费赠送 US LV1 行情（含盘前、盘中、盘后、夜盘全时段）。
> 港股：默认赠送 LV1 行情。
> 美股期权：默认无权限，需购买「OPRA 美股期权行情 (OpenAPI)」行情卡。
> _OpenAPI 行情权限独立于 App/Web 行情权限_

该接口用于获取标的的 K 线数据。

```protobuf
message SecurityCandlestickRequest {
  string symbol = 1;
  Period period = 2;
  int32 count = 3;
  AdjustType adjust_type = 4;
  int32 trade_session = 5;
}

message SecurityCandlestickResponse {
  string symbol = 1;
  repeated Candlestick candlesticks = 2;
}
```

## Request Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `symbol` | string | Yes | 标的代码，使用 ticker.region 格式，例如：700.HK |
| `period` | int32 | Yes | K 线周期 |
| `count` | int32 | Yes | 数据数量；最大 1000 |
| `adjust_type` | int32 | Yes | 复权类型 |
| `trade_session` | int32 | No | 交易时段，0: 盘中，100: 所有（盘前，盘中，盘后，夜盘） |

## Response Fields

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `symbol` | string | No | 标的代码，例如：AAPL.US |
| `candlesticks` | object[] | No | K 线数据 |
| `└ close` | string | No | 当前周期收盘价 |
| `└ open` | string | No | 当前周期开盘价 |
| `└ low` | string | No | 当前周期最低价 |
| `└ high` | string | No | 当前周期最高价 |
| `└ volume` | int64 | No | 当前周期成交量 |
| `└ turnover` | string | No | 当前周期成交额 |
| `└ timestamp` | int64 | No | 当前周期的时间戳 |
| `└ trade_session` | int32 | No | 交易时段 |

## Response JSON Example

```json
{
  "symbol": "700.HK",
  "candlesticks": [
    {
      "close": "362.000",
      "open": "364.600",
      "low": "361.600",
      "high": "368.800",
      "volume": 10853604,
      "turnover": "3954556819.000",
      "timestamp": 1650384000
    }
  ]
}
```
