# 委托下单

`POST` `/v1/trade/order`

该接口用于港美股，窝轮，期权的委托下单。

## Parameters

### Request Body

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `symbol` | string | Yes | 股票代码，使用 `ticker.region` 格式，例如：`AAPL.US` |
| `order_type` | string | Yes | 订单类型。可选值：`LO`、`ELO`、`MO`、`AO`、`ALO`、`ODD`、`LIT`、`MIT`、`TSLPAMT`、`TSLPPCT`、`SLO`。 |
| `submitted_price` | string | No | 下单价格，例如：`388.5`. `LO` / `ELO` / `ALO` / `ODD` / `LIT` 订单必填 |
| `submitted_quantity` | string | Yes | 下单数量，例如：`100`。美股支持碎股数量，例如 `0.05`。美股碎股订单必须将 `outside_rth` 设为 `RTH_ONLY`，否则会被拒单，返回错误码 `603200`。 |
| `trigger_price` | string | No | 触发价格，例如：`388.5`. `LIT` / `MIT` 订单必填 |
| `limit_offset` | string | No | 指定价差，例如 "1.2" 表示价差 1.2 USD (如果是美股). `TSLPAMT` / `TSLPPCT` 订单在 `limit_depth_level` 为 0 时必填 |
| `trailing_amount` | string | No | 跟踪金额。`TSLPAMT` 订单必填 |
| `trailing_percent` | string | No | 跟踪涨跌幅，单位为百分比，例如 "2.5" 表示 "2.5%". `TSLPPCT` 订单必填 |
| `expire_date` | string | No | 长期单过期时间，格式为 `YYYY-MM-DD`, 例如：`2022-12-05`. time_in_force 为 `GTD` 时必填 |
| `side` | string | Yes | 买卖方向。**可选值：**, `Buy` - 买入，`Sell` - 卖出 |
| `outside_rth` | string | No | 是否允许盘前盘后，美股必填。**可选值：**, `RTH_ONLY` - 不允许盘前盘后，`ANY_TIME` - 允许盘前盘后，`OVERNIGHT` - 夜盘，`OPTION_PRE_MARKET` - 夜盘期权 |
| `time_in_force` | string | Yes | 订单有效期类型。**可选值：**, `Day` - 当日有效，`GTC` - 撤单前有效，`GTD` - 到期前有效 |
| `remark` | string | No | 备注 (最大 64 字符) |
| `limit_depth_level` | integer | No | 指定买卖档位，取值范围为 -5 ～ 0 ～ 5，负数代表买盘档位（如 -1 表示买一），, 正数代表卖盘档位（如 1 表示卖一），为 0 时 limit_offset 参数生效，`TSLPAMT` / `TSLPPCT` 订单有效 |
| `monitor_price` | string | No | 监控价格，需要达到该价格才会开始监控，更新参考价，`TSLPAMT` / `TSLPPCT` 订单有效 |
| `trigger_count` | integer | No | 触发次数，取值范围 0 ~ 3, 表示在 1 分钟内触发多次才会触发订单，`LIT` / `MIT` / `TSLPAMT` / `TSLPPCT` 订单有效 |
| `client_request_id` | string | No | 幂等性请求 ID，用于防止重复下单。服务器会缓存该请求 ID 10 分钟。在此期间内如果收到相同 ID 的请求，将返回原始响应而不创建重复订单。必须是唯一标识符（如 UUID）。 |
| `attached_params` | object | No | 附加单参数（止盈止损） |
| `attached_params.attached_order_type` | string | No | 附加单订单类型。**可选值：**, `PROFIT_TAKER` - 止盈，`STOP_LOSS` - 止损，`BRACKET` - 括号单 |
| `attached_params.profit_taker_price` | string | No | 止盈触发价格 |
| `attached_params.stop_loss_price` | string | No | 止损触发价格 |
| `attached_params.time_in_force` | string | No | 附加单有效期类型。**可选值：**, `Day` - 当日有效，`GTC` - 撤单前有效，`GTD` - 到期前有效（此时继承主单 expire_date） |
| `attached_params.expire_time` | integer | No | 到期时间（Unix 时间戳，单位秒） |
| `attached_params.activate_order_type` | string | No | 触发后提交的订单类型，例如 `LIT`（限价单）或 `MIT`（市价单） |
| `attached_params.profit_taker_submit_price` | string | No | 止盈限价委托价格，`activate_order_type` 为 `LIT` 时必填 |
| `attached_params.stop_loss_submit_price` | string | No | 止损限价委托价格，`activate_order_type` 为 `LIT` 时必填 |
| `attached_params.activate_rth` | string | No | 触发后提交的订单是否允许盘前盘后。**可选值：**, `RTH_ONLY` - 不允许盘前盘后，`ANY_TIME` - 允许盘前盘后 |
| `attached_params.profit_taker_depth_level` | integer | No | 止盈限价委托价格的买卖档位，`activate_order_type` 为 `LIT` 时有效 |
| `attached_params.stop_loss_depth_level` | integer | No | 止损限价委托价格的买卖档位，`activate_order_type` 为 `LIT` 时有效 |

## Request Example

```bash
curl --request POST \
  --url 'https://openapi.longbridge.com/v1/trade/order' \
  --header 'Authorization: Bearer <access_token>' \
  --header 'Content-Type: application/json' \
  --data '{"symbol":"<symbol>","order_type":"<order_type>","submitted_price":"<submitted_price>","submitted_quantity":"<submitted_quantity>","trigger_price":"<trigger_price>","limit_offset":"<limit_offset>","trailing_amount":"<trailing_amount>","trailing_percent":"<trailing_percent>","expire_date":"<expire_date>","side":"<side>","outside_rth":"<outside_rth>","time_in_force":"<time_in_force>","remark":"<remark>","limit_depth_level":0,"monitor_price":"<monitor_price>","trigger_count":0,"client_request_id":"<client_request_id>","attached_params":{"attached_order_type":"<attached_order_type>","profit_taker_price":"<profit_taker_price>","stop_loss_price":"<stop_loss_price>","time_in_force":"<time_in_force>","expire_time":0,"activate_order_type":"<activate_order_type>","profit_taker_submit_price":"<profit_taker_submit_price>","stop_loss_submit_price":"<stop_loss_submit_price>","activate_rth":"<activate_rth>"}}'
```

## Response

### Response JSON Example

```json
{
  "code": 0,
  "message": "success",
  "data": {
    "order_id": 683615454870679600
  }
}
```
