交易

委託下單

POSThttps://openapi.longbridge.com/v1/trade/order

鑑權

簽名方式:每個請求用 App Key / Secret 簽名。請求頭如下:

名稱類型必填說明
Authorizationstring · header必填OpenAPI 後台 上的賬戶 Access Token,作為原始 token 傳入(不帶 Bearer 前綴),並參與簽名計算。
X-Api-Keystring · header必填你的 App Key。
X-Timestampstring · header必填請求時間戳,單位秒(Unix 時間)。
X-Api-Signaturestring · header必填HMAC-SHA256 簽名。格式:HMAC-SHA256 SignedHeaders=authorization;x-api-key;x-timestamp, Signature=。

該接口用於港美股,窩輪,期權的委託下單。

>_ CLI
longbridge order buy TSLA.US 100 --price 250.00
longbridge order sell TSLA.US 100 --price 260.00

請求

請求體

名稱類型必填說明
symbolstring必填股票代碼,使用 `ticker.region` 格式,例如:`AAPL.US`
order_typestring必填訂單類型。可選值:`LO`、`ELO`、`MO`、`AO`、`ALO`、`ODD`、`LIT`、`MIT`、`TSLPAMT`、`TSLPPCT`、`SLO`。
submitted_pricestring可選下單價格,例如:`388.5`. `LO` / `ELO` / `ALO` / `ODD` / `LIT` 訂單必填
submitted_quantitystring必填下單數量,例如:`100`。美股支持碎股數量,例如 `0.05`。美股碎股訂單必須將 `outside_rth` 設為 `RTH_ONLY`,否則會被拒單,返回錯誤碼 `603200`。
trigger_pricestring可選觸發價格,例如:`388.5`. `LIT` / `MIT` 訂單必填
limit_offsetstring可選指定價差。`TSLPAMT` / `TSLPPCT` 訂單在 `limit_depth_level` 為 0 時必填
trailing_amountstring可選跟蹤金額。`TSLPAMT` 訂單必填
trailing_percentstring可選跟蹤漲跌幅。`TSLPPCT` 訂單必填
expire_datestring可選長期單過期時間,格式為 `YYYY-MM-DD`, 例如:`2022-12-05`. time_in_force 為 `GTD` 時必填
sidestring必填買賣方向。**可選值:**, `Buy` - 買入,`Sell` - 賣出
outside_rthstring可選是否允許盤前盤後,美股必填。**可選值:**, `RTH_ONLY` - 不允許盤前盤後,`ANY_TIME` - 允許盤前盤後,`OVERNIGHT` - 夜盤,`OPTION_PRE_MARKET` - 夜盤期權
time_in_forcestring必填訂單有效期類型。**可選值:**, `Day` - 當日有效,`GTC` - 撤單前有效,`GTD` - 到期前有效
remarkstring可選備註 (最大 64 字符)
limit_depth_levelinteger可選指定買賣檔位,取值範圍為 -5 ~ 0 ~ 5,負數代表買盤檔位(例如 -1 表示買一),, 正數代表賣盤檔位(例如 1 表示賣一),當為 0 時 limit_offset 參數生效,`TSLPAMT` / `TSLPPCT` 訂單有效
monitor_pricestring可選監控價格,需要達到該價格才會開始監控,更新參考價,`TSLPAMT` / `TSLPPCT` 訂單有效
trigger_countinteger可選觸發次數,取值範圍 0 ~ 3,表示在 1 分鐘內觸發多次才會觸發訂單,, `LIT` / `MIT` / `TSLPAMT` / `TSLPPCT` 訂單有效
client_request_idstring可選冪等性請求 ID,用於防止重複下單。服務器會快取該請求 ID 10 分鐘。在此期間內如果收到相同 ID 的請求,將返回原始響應而不建立重複訂單。必須是唯一標識符(如 UUID)。
attached_paramsobject可選附加單參數(止盈止損)
attached_params.attached_order_typestring可選附加單訂單類型。**可選值:**, `PROFIT_TAKER` - 止盈,`STOP_LOSS` - 止損,`BRACKET` - 括號單
attached_params.profit_taker_pricestring可選止盈觸發價格
attached_params.stop_loss_pricestring可選止損觸發價格
attached_params.time_in_forcestring可選附加單有效期類型。**可選值:**, `Day` - 當日有效,`GTC` - 撤單前有效,`GTD` - 到期前有效(此時繼承主單 expire_date)
attached_params.expire_timeinteger可選到期時間(Unix 時間戳,單位秒)
attached_params.activate_order_typestring可選觸發後提交的訂單類型,例如 `LIT`(限價單)或 `MIT`(市價單)
attached_params.profit_taker_submit_pricestring可選止盈限價委託價格,`activate_order_type` 為 `LIT` 時必填
attached_params.stop_loss_submit_pricestring可選止損限價委託價格,`activate_order_type` 為 `LIT` 時必填
attached_params.activate_rthstring可選觸發後提交的訂單是否允許盤前盤後。**可選值:**, `RTH_ONLY` - 不允許盤前盤後,`ANY_TIME` - 允許盤前盤後
attached_params.profit_taker_depth_levelinteger可選止盈限價委託價格的買賣檔位,`activate_order_type` 為 `LIT` 時有效
attached_params.stop_loss_depth_levelinteger可選止損限價委託價格的買賣檔位,`activate_order_type` 為 `LIT` 時有效

響應

響應 JSON 示例

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

錯誤碼

參見錯誤碼文檔。