委托下单
该接口用于港美股,窝轮,期权的委托下单
Request
HTTP Method | POST |
HTTP URL | /v1/trade/order |
Parameters
Content-Type: application/json; charset=utf-8
Name | Type | Required | Description |
---|---|---|---|
symbol | string | YES | 股票代码,使用 ticker.region 格式,例如:AAPL.US |
order_type | string | YES | 订单类型 |
submitted_price | string | NO | 下单价格,例如:388.5 LO / ELO / ALO / ODD / LIT 订单必填 |
submitted_quantity | string | YES | 下单数量,例如:100 |
trigger_price | string | NO | 触发价格,例如:388.5 LIT / MIT 订单必填 |
limit_offset | string | NO | 指定价差TSLPAMT / TSLPPCT 订单必填 |
trailing_amount | string | NO | 跟踪金额TSLPAMT / TSMAMT 订单必填 |
trailing_percent | string | NO | 跟踪涨跌幅TSLPPCT / TSMPCT 订单必填 |
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 - 允许盘前盘后 |
time_in_force | string | YES | 订单有效期类型 可选值: Day - 当日有效GTC - 撤单前有效GTD - 到期前有效 |
remark | string | NO | 备注 (最大 64 字符) |
Request Example
from decimal import Decimal
from longport.openapi import TradeContext, Config, OrderType, OrderSide, TimeInForceType
# Load configuration from environment variables
config = Config.from_env()
# Create a context for trade APIs
ctx = TradeContext(config)
# Submit order
resp = ctx.submit_order("700.HK", OrderType.LO, OrderSide.Buy, Decimal(
"500"), TimeInForceType.Day, submitted_price=Decimal("50"), remark="Hello from Python SDK")
print(resp)
Response
Response Headers
- Content-Type: application/json
Response Example
{
"code": 0,
"message": "success",
"data": {
"order_id": 683615454870679600
}
}
Response Status
Status | Description | Schema |
---|---|---|
200 | 提交成功,订单已委托。 | None |
400 | 下单被拒绝,请求参数错误。 | None |