Submit Order
This API is used to submit order for HK and US stocks, warrant and option.
SDK Links
Python | longport.openapi.TradeContext.submit_order |
Rust | longport::trade::TradeContext#submit_order |
Go | TradeContext.SubmitOrder |
Node.js | TradeContext#submitOrder |
Request
| HTTP Method | POST |
| HTTP URL | /v1/trade/order |
Parameters
Content-Type: application/json; charset=utf-8
| Name | Type | Required | Description |
|---|---|---|---|
| symbol | string | YES | Stock symbol, use ticker.region format, example: AAPL.US |
| order_type | string | YES | Order Type |
| submitted_price | string | NO | Submitted price, example: 388.5LO / ELO / ALO / ODD / LIT Order Required |
| submitted_quantity | string | YES | Submitted quantity, example: 100 |
| trigger_price | string | NO | Trigger price, example: 388.5LIT / MIT Order Required |
| limit_offset | string | NO | Limit offset amountTSLPAMT / TSLPPCT Order Required |
| trailing_amount | string | NO | Trailing amountTSLPAMT Order Required |
| trailing_percent | string | NO | Trailing percentTSLPPCT Order Required |
| expire_date | string | NO | Long term order expire date, format YYYY-MM-DD, example: 2022-12-05Required when time_in_force is GTD |
| side | string | YES | Order Side Enum Value: BuySell |
| outside_rth | string | NO | Enable or disable outside regular trading hours Enum Value: RTH_ONLY - regular trading hour onlyANY_TIME - any timeOVERNIGHT - Overnight" |
| time_in_force | string | YES | Time in force Type Enum Value: Day - Day OrderGTC - Good Til Canceled OrderGTD - Good Til Date Order |
| remark | string | NO | remark (Maximum 64 characters) |
Request Example
python
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
json
{
"code": 0,
"message": "success",
"data": {
"order_id": 683615454870679600
}
}Response Status
| Status | Description | Schema |
|---|---|---|
| 200 | The submission was successful and the order was commissioned. | None |
| 400 | The submit was rejected with an incorrect request parameter. | None |