Skip to main content

Submit Order

This API is used to submit order for HK and US stocks, warrant and option

Request

HTTP MethodPOST
HTTP URL/v1/trade/order

Parameters

Content-Type: application/json; charset=utf-8

NameTypeRequiredDescription
symbolstringYESStock symbol, use ticker.region format, example: AAPL.US
order_typestringYESOrder Type
submitted_pricestringNOSubmitted price, example: 388.5

LO / ELO / ALO / ODD / LIT Order Required
submitted_quantitystringYESSubmitted quantity, example: 100
trigger_pricestringNOTrigger price, example: 388.5

LIT / MIT Order Required
limit_offsetstringNOLimit offset amount

TSLPAMT / TSLPPCT Order Required
trailing_amountstringNOTrailing amount

TSLPAMT Order Required
trailing_percentstringNOTrailing percent

TSLPPCT Order Required
expire_datestringNOLong term order expire date, format YYYY-MM-DD, example: 2022-12-05

Required when time_in_force is GTD
sidestringYESOrder Side

Enum Value:
Buy
Sell
outside_rthstringNOEnable or disable outside regular trading hours

Enum Value:
RTH_ONLY - regular trading hour only
ANY_TIME - any time"
time_in_forcestringYESTime in force Type

Enum Value:
Day - Day Order
GTC - Good Til Canceled Order
GTD - Good Til Date Order
remarkstringNOremark (Maximum 64 characters)

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

StatusDescriptionSchema
200The submission was successful and the order was commissioned.None
400The submit was rejected with an incorrect request parameter.None