XtQuant 委托申报相关 数据字典与API说明整理(250724)

PTD 阅读:32 2025-07-24 13:50:10 评论:0

交易市场(market)

市场 常量
上交所 xtconstant.SH_MARKET
深交所 xtconstant.SZ_MARKET

账号类型(account_type)

类型 常量
股票 xtconstant.SECURITY_ACCOUNT

委托类型(order_type)

类型 常量
股票买入 xtconstant.STOCK_BUY
股票卖出 xtconstant.STOCK_SELL

报价类型(price_type)

类型 常量
最新价 xtconstant.LATEST_PRICE
指定价 xtconstant.FIX_PRICE

委托状态(order_status)

状态 常量 含义
未报 xtconstant.ORDER_UNREPORTED 48 未报
待报 xtconstant.ORDER_WAIT_REPORTING 49 待报
已报 xtconstant.ORDER_REPORTED 50 已报
已报待撤 xtconstant.ORDER_REPORTED_CANCEL 51 已报待撤
部成待撤 xtconstant.ORDER_PARTSUCC_CANCEL 52 部成待撤
部撤 xtconstant.ORDER_PART_CANCEL 53 已经有一部分成交,剩下的已撤单
已撤 xtconstant.ORDER_CANCELED 54 已撤
部成 xtconstant.ORDER_PART_SUCC 55 已经有一部分成交,剩下的待成交
已成 xtconstant.ORDER_SUCCEEDED 56 已成
废单 xtconstant.ORDER_JUNK 57 废单
未知 xtconstant.ORDER_UNKNOWN 255 未知

价格类型(enum_EBrokerPriceType)

类型 常量
市价 BROKER_PRICE_ANY 49
限价 BROKER_PRICE_LIMIT 50
最优价 BROKER_PRICE_BEST 51

数据结构

XtOrder (委托)

属性 类型 说明
account_type int 账号类型
account_id str 资金账号
stock_code str 证券代码,如”600000.SH”
order_id int 订单编号
order_sysid str 柜台合同编号
order_time int 报单时间
order_type int 委托类型
order_volume int 委托数量
price_type int 报价类型
price float 委托价格
traded_volume int 成交数量
traded_price float 成交均价
order_status int 委托状态
status_msg str 委托状态描述
strategy_name str 策略名称
order_remark str 委托备注(最大24英文字符)

XtTrade (成交)

属性 类型 说明
account_type int 账号类型
account_id str 资金账号
stock_code str 证券代码
order_type int 委托类型
traded_id str 成交编号
traded_time int 成交时间
traded_price float 成交均价
traded_volume int 成交数量
traded_amount float 成交金额
order_id int 订单编号
order_sysid str 柜台合同编号
strategy_name str 策略名称
order_remark str 委托备注

XtOrderError (下单失败错误)

属性 类型 说明
account_type int 账号类型
account_id str 资金账号
order_id int 订单编号
error_id int 下单失败错误码
error_msg str 下单失败具体信息
strategy_name str 策略名称
order_remark str 委托备注

XtCancelError (撤单失败错误)

属性 类型 说明
account_type int 账号类型
account_id str 资金账号
order_id int 订单编号
market int 交易市场(0:上海 1:深圳)
order_sysid str 柜台委托编号
error_id int 下单失败错误码
error_msg str 下单失败具体信息

API接口

操作接口

  1. 股票同步报单

    order_stock(account, stock_code, order_type, order_volume, price_type, price, strategy_name, order_remark)
    
    • 返回: 订单编号(>0成功, -1失败)
  2. 股票异步报单

    order_stock_async(account, stock_code, order_type, order_volume, price_type, price, strategy_name, order_remark)
    
    • 返回: 请求序号(>0成功, -1失败)
  3. 股票同步撤单(按订单编号)

    cancel_order_stock(account, order_id)
    
    • 返回: 0成功, -1失败
  4. 股票同步撤单(按柜台编号)

    cancel_order_stock_sysid(account, market, order_sysid)
    
    • 返回: 0成功, -1失败
  5. 股票异步撤单(按订单编号)

    cancel_order_stock_async(account, order_id)
    
    • 返回: 请求序号(>0成功, -1失败)
  6. 股票异步撤单(按柜台编号)

    cancel_order_stock_sysid_async(account, market, order_sysid)
    

查询接口

  1. 委托查询

    query_stock_orders(account, cancelable_only=False)
    
    • 返回: XtOrder列表或None
  2. 成交查询

    query_stock_trades(account)
    
    • 返回: XtTrade列表或None

回调类

class MyXtQuantTraderCallback(XtQuantTraderCallback):
    def on_disconnected(self):
        """连接断开回调"""
        
    def on_account_status(self, status):
        """账号状态信息推送"""
        
    def on_stock_order(self, order):
        """委托信息推送"""
        
    def on_stock_trade(self, trade):
        """成交信息推送"""
        
    def on_order_error(self, order_error):
        """下单失败信息推送"""
        
    def on_cancel_error(self, cancel_error):
        """撤单失败信息推送"""
        
    def on_order_stock_async_response(self, response):
        """异步下单回报推送"""
        
    def on_smt_appointment_async_response(self, response):
        """预约异步回报推送"""

本文由 海星量化研究所 作者提供,转载请保留链接和署名!网址:https://qmt.hxquant.com/?id=48

声明

1.本站原创文章,转载需注明文章作者来源。 2.如果文章内容涉及版权问题,请联系我们删除,向本站投稿文章可能会经我们编辑修改。 3.本站对信息准确性或完整性不作保证,亦不对因使用该等信息而引发或可能引发的损失承担任何责任。

搜索
排行榜
关注我们

扫码开通QMT/ptrade