# 成交明細

`WS` `request · cmd 17`

> **行情權限要求 · 免費**
> 美股：預設免費贈送 US LV1 實時行情（近 1000 筆，含盤前、盤中、盤後、夜盤全時段）。
> 港股：預設贈送 LV1 實時行情（近 1000 筆）。
> 美股期權：預設無權限，需購買「OPRA 美股期權行情 (OpenAPI)」行情卡，最多可獲取近 1000 筆。
> _OpenAPI 行情權限獨立於 App/Web 行情權限_

該接口用於獲取標的的成交明細數據。

```protobuf
message SecurityTradeRequest {
  string symbol = 1;
  int32 count = 2;
}

message SecurityTradeResponse {
  string symbol = 1;
  repeated Trade trades = 2;
}
```

## Request Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `symbol` | string | Yes | 標的代碼，使用 ticker.region 格式，例如：700.HK |
| `count` | int32 | Yes | 請求的逐筆明細數量；最大 1000 |

## Response Fields

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `symbol` | string | No | 標的代碼 |
| `trades` | object[] | No | 逐筆明細數據 |
| `└ price` | string | No | 價格 |
| `└ volume` | int64 | No | 成交量 |
| `└ timestamp` | int64 | No | 成交時間 |
| `└ trade_type` | string | No | 交易類型說明 |
| `└ direction` | int32 | No | 交易方向 (0-neutral, 1-down, 2-up) |
| `└ trade_session` | int32 | No | 交易時段 |

## Response JSON Example

```json
{
  "symbol": "AAPL.US",
  "trades": [
    {
      "price": "158.760",
      "volume": 1,
      "timestamp": 1651103979,
      "trade_type": "I",
      "direction": 0,
      "trade_session": 2
    }
  ]
}
```
