QMT · 内置 Python交易函数
get_last_order_id
获取最新的委托或成交的委托Id
原型
get_last_order_id(accountID, strAccountType, strDatatype)
get_last_order_id(accountID, strAccountType, strDatatype, strategyName)
参数
| 参数 | 类型 | 说明 |
|---|---|---|
| accountID | string | 资金账号。 |
| strAccountType | string | FUTURE、STOCK、CREDIT、HUGANGTONG、SHENGANGTONG、STOCK_OPTION。 |
| strDatatype | string | ORDER(委托)或 DEAL(成交)。 |
| strategyName | string,可省略 | 对应 passorder 的策略名。 |
返回值
String,委托号,如果没找到返回"-1".
示例
以下代码依据官方示例整理缩进,并将旧式 print 写法改为函数调用;账号使用占位值。
def init(ContextInfo):
ContextInfo.accid = 'YOUR_ACCOUNT_ID'
def handlebar(ContextInfo):
order_id = get_last_order_id(ContextInfo.accid, 'STOCK', 'ORDER')
print(order_id)
补充说明
get_last_order_id (accountID,strAccountType,strDatatype); 或者get_last_order_id(accountID,strAccountType,strDatatype,strategyName);
使用注意
下单后获取委托号存在不确定延迟;如果本次委托废单,查询可能仍返回上一次成功下单的委托号。不能把查询得到委托号直接视为本次委托已成交。
官方来源
迅投 QMT 官方函数检索表,条目 get_last_order_id。本页属于 QMT 内置 Python 接口;原站函数检索表同时收录其他语言,不能按网页路径将本条目误归为 VBA。网页核对日期:2026-10-11。