跳到主要內容

获取当日订单

该接口用于获取当日订单和订单查询

Request

HTTP MethodGET
HTTP URL/v1/trade/order/today

Parameters

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

NameTypeRequiredDescription
symbolstringNO股票代码,使用 ticker.region 格式,例如:AAPL.US
statusstring[]NO订单状态

例如:status=FilledStatus&status=NewStatus
sidestringNO买卖方向

可选值:
Buy - 买入
Sell - 卖出
marketstringNO市场

可选值:
US - 美股
HK - 港股
order_idstringNO订单 ID,用于指定订单 ID 查询,例如:701276261045858304

Request Example

from longport.openapi import TradeContext, Config, OrderStatus, OrderSide, Market

config = Config.from_env()
ctx = TradeContext(config)

resp = ctx.today_orders(
symbol = "700.HK",
status = [OrderStatus.Filled, OrderStatus.New],
side = OrderSide.Buy,
market = Market.HK,
)
print(resp)

Response

Response Headers

  • Content-Type: application/json

Response Example

{
"code": 0,
"message": "success",
"data": {
"orders": [
{
"currency": "HKD",
"executed_price": "0.000",
"executed_quantity": "0",
"expire_date": "",
"last_done": "",
"limit_offset": "",
"msg": "",
"order_id": "706388312699592704",
"order_type": "ELO",
"outside_rth": "UnknownOutsideRth",
"price": "11.900",
"quantity": "200",
"side": "Buy",
"status": "RejectedStatus",
"stock_name": "东亚银行",
"submitted_at": "1651644897",
"symbol": "23.HK",
"tag": "Normal",
"time_in_force": "Day",
"trailing_amount": "",
"trailing_percent": "",
"trigger_at": "0",
"trigger_price": "",
"trigger_status": "NOT_USED",
"updated_at": "1651644898",
"remark": ""
}
]
}
}

Response Status

StatusDescriptionSchema
200当日订单查询成功today_orders_rsp
400查询失败,请求参数错误。None

Schemas

today_orders_rsp

NameTypeRequiredDescription
ordersobject[]false订单信息
∟ order_idstringtrue订单 ID
∟ statusstringtrue订单状态
∟ stock_namestringtrue股票名称
∟ quantitystringtrue下单数量
∟ executed_quantitystringtrue成交数量。

当订单未成交时为 0
∟ pricestringtrue下单价格。

当市价条件单未触发时为空字符串
∟ executed_pricestringtrue成交价。

当订单未成交时为 0
∟ submitted_atstringtrue下单时间
∟ sidestringtrue买卖方向

可选值:
Buy - 买入
Sell - 卖出
∟ symbolstringtrue股票代码,使用 ticker.region 格式,例如:AAPL.US
∟ order_typestringtrue订单类型
∟ last_donestringtrue最近成交价格。

当订单未成交时为空字符串
∟ trigger_pricestringtrueLIT / MIT 订单触发价格。

当订单不是 LIT / MIT 订单为空字符串
∟ msgstringtrue拒绝信息或备注,默认为空字符串。
∟ tagstringtrue订单标记

可选值:
Normal - 普通订单
GTC - 长期单
Grey - 暗盘单
∟ time_in_forcestringtrue订单有效期类型

可选值:
Day - 当日有效
GTC - 撤单前有效
GTD - 到期前有效
∟ expire_datestringtrue长期单过期时间,格式为 YYYY-MM-DD, 例如:2022-12-05。<br/><br/>不是长期单时,默认为空字符串。
∟ updated_atstringtrue最近更新时间,格式为时间戳 (秒),默认为 0。
∟ trigger_atstringtrue条件单触发时间,格式为时间戳 (秒),默认为 0。
∟ trailing_amountstringtrueTSLPAMT / TSMAMT 订单跟踪金额。

当订单不是 TSLPAMT / TSMAMT 订单时为空字符串。
∟ trailing_percentstringtrueTSLPPCT / TSMPCT 订单跟踪涨跌幅。

当订单不是 TSLPPCT / TSMPCT 订单时为空字符串。
∟ limit_offsetstringtrueTSLPAMT / TSLPPCT 订单指定价差。

当订单不是 TSLPAMT / TSLPPCT 订单时为空字符串。
∟ trigger_statusstringtrue条件单触发状态
当订单不是条件单或条件单未触发时, 触发状态为 NOT_USED

可选值:
NOT_USED - 未激活 DEACTIVE - 已失效 ACTIVE - 已激活 RELEASED - 已触发
∟ currencystringtrue结算货币
∟ outside_rthstringtrue是否允许盘前盘后
当订单不是美股时, 默认为 UnknownOutsideRth

可选值:
RTH_ONLY - 不允许盘前盘后
ANY_TIME - 允许盘前盘后"
∟ remarkstringtrue备注