QMT · 内置 Python交易函数
get_value_by_order_id
调用方法 get_value_by_order_id(orderId, accountID, strAccountType, strDatatype)
调用方法get_value_by_order_id(orderId, accountID, strAccountType, strDatatype)
参数
| 参数名 | 类型 | 含义 | 说明 |
|---|---|---|---|
| orderId | string | 委托号 | 必填 |
| accountID | string | 资金账号 | 必填 |
| strAccountType | string | 账号类型 可选: 'FUTURE':期货 'STOCK':股票 'CREDIT':信用 'HUGANGTONG':沪港通 'SHENGANGTONG':深港通 'STOCK_OPTION':期权 |
必填 |
| strDatatype | string | 要查询数据类型 可选: 'ORDER':委托 'DEAL' :成交 |
必填 |
返回值
示例
def init(ContextInfo):
ContextInfo.accid = '6000000248'
def handlebar(ContextInfo):
orderid = get_last_order_id(ContextInfo.accid, 'stock', 'order')
print(orderid)
obj = get_value_by_order_id(orderid,ContextInfo.accid, 'stock', 'order')
print(obj.m_strInstrumentID)
返回值
【2023-10-31 13:20:51.440】 [quote]start simulation mode
【2023-10-31 13:20:51.464】 719000001
000001
get_last_order_id-获取最新的委托或成交的委托号
获取最新的委托或成交的委托号
提示
注意,下单后需要一段不确定的时间才能查询到此次委托的委托号,而且如果委托废单,则只能查询到上次成功下单的委托号
调用方法
# 区分策略,添加策略名称参数 strategyName
get_last_order_id(accountID, strAccountType, strDatatype, strategyName)
# 不区分策略
get_last_order_id(accountID, strAccountType, strDatatype)
参数
| 参数名 | 类型 | 含义 | 说明 |
|---|---|---|---|
| accountID | string | 资金账号 | 必填 |
| strAccountType | string | 账号类型 可选: 'FUTURE':期货 'STOCK':股票 'CREDIT':信用 'HUGANGTONG':沪港通 'SHENGANGTONG':深港通 'STOCK_OPTION':期权 |
必填 |
| strDatatype | string | 要查询数据类型 可选: 'ORDER':委托 'DEAL' :成交 |
必填 |
| strategyName | string | 策略 当用passorder下单时指定了strategyName 参数时,当查询成交和委托时传入同样的strageName,则可以只返回包含strategyName的委托子集或成交子集 | 选填 |
返回值
String,委托号,如果没找到返回 '-1'。
示例
def init(ContextInfo):
ContextInfo.accid = '6000000248'
def handlebar(ContextInfo):
orderid = get_last_order_id(ContextInfo.accid, 'stock', 'order')
print(orderid)
obj = get_value_by_order_id(orderid,ContextInfo.accid, 'stock', 'order')
print(obj.m_strInstrumentID)
官方来源
QMT 官方文档:根据委托号获取委托或成交信息。网页核对日期:2026-10-11。