# 歷史訂單

`GET` `/v1/trade/order/history`

該接口用於獲取歷史訂單。

## Parameters

### Query Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `symbol` | string | No | 股票代碼，使用 `ticker.region` 格式，例如：`AAPL.US` |
| `status` | array | No | 訂單狀態。可選值：`NotReported`、`ReplacedNotReported`、`ProtectedNotReported`、`VarietiesNotReported`、`DelayedNotReported`、`FilledStatus`、`WaitToNew`、`NewStatus`、`WaitToReplace`、`PendingReplaceStatus`、`ReplacedStatus`、`PartialFilledStatus`、`WaitToCancel`、`PendingCancelStatus`、`RejectedStatus`、`CanceledStatus`、`ExpiredStatus`、`PartialWithdrawal`。. 例如：`status=FilledStatus&status=NewStatus` |
| `side` | string | No | 買賣方向。**可選值：**, `Buy` - 買入，`Sell` - 賣出 |
| `market` | string | No | 市場。**可選值：**, `US` - 美股，`HK` - 港股 |
| `start_at` | string | No | 開始時間，格式為時間戳 (秒)，例如：`1650410999`。. 開始時間為空時，默認為結束時間或當前時間前九十天。 |
| `end_at` | string | No | 結束時間，格式為時間戳 (秒)，例如：`1650410999`。. 結束時間為空時，默認為開始時間後九十天或當前時間。 |

## Request Example

```bash
curl --request GET \
  --url 'https://openapi.longbridge.com/v1/trade/order/history' \
  --header 'Authorization: Bearer <access_token>'
```

## Response

### Response Properties

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `orders` | object[] | No | 訂單信息 |
| `└ order_id` | string | No | 訂單 ID |
| `└ status` | string | No | 訂單狀態。可選值：`NotReported`、`ReplacedNotReported`、`ProtectedNotReported`、`VarietiesNotReported`、`DelayedNotReported`、`FilledStatus`、`WaitToNew`、`NewStatus`、`WaitToReplace`、`PendingReplaceStatus`、`ReplacedStatus`、`PartialFilledStatus`、`WaitToCancel`、`PendingCancelStatus`、`RejectedStatus`、`CanceledStatus`、`ExpiredStatus`、`PartialWithdrawal`。 |
| `└ stock_name` | string | No | 股票名稱 |
| `└ quantity` | string | No | 下單數量 |
| `└ executed_quantity` | string | No | 成交數量。. 當訂單未成交時為 0 |
| `└ price` | string | No | 下單價格。. 當市價條件單未觸發時為空字符串 |
| `└ executed_price` | string | No | 成交價。. 當訂單未成交時為 0 |
| `└ submitted_at` | string | No | 下單時間 |
| `└ side` | string | No | 買賣方向。**可選值：**, `Buy` - 買入，`Sell` - 賣出 |
| `└ symbol` | string | No | 股票代碼，使用 `ticker.region` 格式，例如：`AAPL.US` |
| `└ order_type` | string | No | 訂單類型。可選值：`LO`、`ELO`、`MO`、`AO`、`ALO`、`ODD`、`LIT`、`MIT`、`TSLPAMT`、`TSLPPCT`、`SLO`。 |
| `└ trigger_price` | string | No | `LIT` / `MIT` 訂單觸發價格。. 當訂單不是 `LIT` / `MIT` 訂單為空字符串 |
| `└ tag` | string | No | 訂單標記。**可選值：**, `Normal` - 普通訂單，`Gtc` - 長期單，`Grey` - 暗盤單 |
| `└ time_in_force` | string | No | 訂單有效期類型。**可選值：**, `Day` - 當日有效，`GTC` - 撤單前有效，`GTD` - 到期前有效 |
| `└ expire_date` | string | No | 長期單過期時間，格式為 `YYYY-MM-DD`, 例如：`2022-12-05。. 不是長期單時，默認為空字符串。` |
| `└ updated_at` | string | No | 最近更新時間，格式為時間戳 (秒)，默認為 0。 |
| `└ trigger_at` | string | No | 條件單觸發時間，格式為時間戳 (秒)，默認為 0。 |
| `└ trigger_status` | string | No | 條件單觸發狀態，當訂單不是條件單或條件單未觸發時，觸發狀態為 NOT_USED. **可選值：**, `NOT_USED` - 未激活 `DEACTIVE` - 已失效 `ACTIVE` - 已激活 `RELEASED` - 已觸發 |
| `└ outside_rth` | string | No | 是否允許盤前盤後，當訂單不是美股時，默認為 UnknownOutsideRth. **可選值：**, `RTH_ONLY` - 不允許盤前盤後，`ANY_TIME` - 允許盤前盤後，`OVERNIGHT` - 夜盤 |
| `└ currency` | string | No | 結算貨幣 |
| `└ limit_depth_level` | integer | No | 指定買賣檔位 |
| `└ trigger_count` | integer | No | 觸發次數 |
| `└ trigger_qty_type` | integer | No | 觸發數量類型。 |
| `└ attached_orders` | array | No | 附加訂單詳情列表 |
| `└ last_done` | string | No | 最近成交價格。. 當訂單未成交時為空字符串 |
| `└ msg` | string | No | 拒絕信息或備註，默認為空字符串。 |
| `└ trailing_amount` | string | No | `TSLPAMT` 訂單跟蹤金額。. 當訂單不是 `TSLPAMT` 訂單時為空字符串。 |
| `└ trailing_percent` | string | No | `TSLPPCT` 訂單跟蹤漲跌幅。. 當訂單不是 `TSLPPCT` 訂單時為空字符串。 |
| `└ limit_offset` | string | No | `TSLPAMT` / `TSLPPCT` 訂單指定價差。. 當訂單不是 `TSLPAMT` / `TSLPPCT` 訂單時為空字符串。 |
| `└ remark` | string | No | 備註 |
| `└ monitor_price` | string | No | 監控價格 |
| `└ monitor_counter_id` | string | No | 監控標的內部標識（條件單）。 |
| `└ multi_leg` | string | No | 多腿策略信息，僅多腿期權組合訂單返回，非組合訂單不返回。 |
| `has_more` | boolean | No | 是否還有更多數據。. 每次查詢最大訂單數量為 1000，如果查詢結果數量超過 1000，那麼 has_more 就會為 true |

### Response JSON Example

```json
{
  "code": 0,
  "message": "success",
  "data": {
    "orders": [
      {
        "currency": "HKD",
        "executed_price": "0.000",
        "executed_quantity": "0",
        "expire_date": "",
        "last_done": "",
        "limit_offset": "",
        "msg": "",
        "order_id": "706388312699592704",
        "order_type": "ELO",
        "outside_rth": "UnknownOutsideRth",
        "price": "11.900",
        "quantity": "200",
        "side": "Buy",
        "status": "RejectedStatus",
        "stock_name": "Bank of East Asia Ltd/The",
        "submitted_at": "1651644897",
        "symbol": "23.HK",
        "tag": "Normal",
        "time_in_force": "Day",
        "trailing_amount": "",
        "trailing_percent": "",
        "trigger_at": "0",
        "trigger_price": "",
        "trigger_status": "NOT_USED",
        "updated_at": "1651644898",
        "remark": "",
        "limit_depth_level": 0,
        "monitor_price": "",
        "trigger_count": 1,
        "attached_orders": [
          {
            "order_id": "706388312699592705",
            "attached_type_display": 2,
            "trigger_price": "10.500",
            "quantity": "200",
            "executed_qty": "0",
            "status": "NewStatus",
            "updated_at": "1651644898",
            "withdrawn": false,
            "gtd": "",
            "time_in_force": "Day",
            "counter_id": "",
            "trigger_status": 0,
            "executed_amount": "0",
            "tag": 0,
            "submitted_at": "1651644897",
            "executed_price": "0.000",
            "force_only_rth": "RTH_ONLY",
            "reviewed": false,
            "activate_order_type": "MIT",
            "activate_rth": "RTH_ONLY",
            "submit_price": ""
          }
        ],
        "multi_leg": {
          "strategy": "2",
          "strategy_name": "Vertical spread",
          "multileg_id": "Spread_QQQ20260731C764/767",
          "code": "QQQ 260731 764/767 Vertical spread",
          "legs": [
            {
              "symbol": "QQQ260731C764000.US",
              "side": "Buy",
              "position": "LONG",
              "ratio_quantity": "1",
              "strike_price": "764",
              "expire_date": "20260731",
              "contract_direction": "C"
            },
            {
              "symbol": "QQQ260731C767000.US",
              "side": "Sell",
              "position": "SHORT",
              "ratio_quantity": "1",
              "strike_price": "767",
              "expire_date": "20260731",
              "contract_direction": "C"
            }
          ]
        }
      }
    ]
  }
}
```
