2026年QMT极简版调用教程[源码]

QMT极简版调用教程[源码]迅投 QMT 交易回调处理模块 来源 https blog csdn net liuyukuan article details from xtquant xttrader import XtQuantTrade import

大家好,我是讯享网,很高兴认识大家。这里提供最前沿的Ai技术和互联网信息。

""" 迅投 QMT 交易回调处理模块 来源:https://blog.csdn.net/liuyukuan/article/details/ """

from xtquant.xttrader import XtQuantTraderCallback import time import datetime import traceback import sys

class MyXtQuantTraderCallback(XtQuantTraderCallback):

"""自定义交易回调处理类""" def on_disconnected(self): """ 连接状态回调 :return: """ print(datetime.datetime.now(), "连接断开 connection lost") def on_account_status(self, status): """ 账号状态信息推送 :param status: XtAccountStatus 对象 :return: """ print("账号状态信息推送 on_account_status") print(status.account_id, status.account_type, status.status) print(datetime.datetime.now(), sys._getframe().f_code.co_name) def on_stock_asset(self, asset): """ 资金变动推送 :param asset: XtAsset 对象 :return: """ print("资金变动推送 on asset callback") print(asset.account_id, asset.cash, asset.total_asset) def on_stock_order(self, order): """ 委托回报推送 :param order: XtOrder 对象 :return: """ print(datetime.datetime.now(), '委托回调', order.order_remark) print(order.stock_code, order.order_status, order.order_sysid) def on_stock_trade(self, trade): """ 成交变动推送 :param trade: XtTrade 对象 :return: """ print(datetime.datetime.now(), '成交回调', trade.order_remark) print(trade.account_id, trade.stock_code, trade.order_id) def on_stock_position(self, position): """ 持仓变动推送 :param position: XtPosition 对象 :return: """ print("on position callback") print(position.stock_code, position.volume) def on_order_error(self, order_error): """ 委托失败推送 :param order_error: XtOrderError 对象 :return: """ print("委托失败单号【", order_error.order_id, "】 

",

 "失败错误码:", order_error.error_id, " 

",

 "失败具体说明:", order_error.error_msg) def on_cancel_error(self, cancel_error): """ 撤单失败信息推送 :param cancel_error: XtCancelError 对象 :return: """ print("on cancel_error callback") print(cancel_error.order_id, cancel_error.error_id, cancel_error.error_msg) def on_order_stock_async_response(self, response): """ 异步下单回报推送 :param response: XtOrderResponse 对象 :return: """ print(f"异步委托回调 {response.order_remark}") print(response.account_id, response.order_id, response.seq) def on_cancel_order_stock_async_response(self, response): """ 撤单异步回调 :param response: XtCancelOrderResponse 对象 :return: """ print(datetime.datetime.now(), sys._getframe().f_code.co_name) print(response.account_id, response.order_id, response.seq) 
小讯
上一篇 2026-04-26 18:14
下一篇 2026-04-26 18:12

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/281119.html