init
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
|
||||
from xttrader import XtQuantTraderCallback
|
||||
import datetime
|
||||
|
||||
class MyXtQuantTraderCallback(XtQuantTraderCallback):
|
||||
|
||||
def on_disconnected(self):
|
||||
"""
|
||||
连接断开
|
||||
:return:
|
||||
"""
|
||||
print(datetime.datetime.now(), '连接断开回调')
|
||||
|
||||
def on_stock_order(self, order):
|
||||
"""
|
||||
委托回报推送
|
||||
:param order: XtOrder对象
|
||||
:return:
|
||||
"""
|
||||
print(datetime.datetime.now(), '委托回调 投资备注', order.order_remark)
|
||||
|
||||
def on_stock_trade(self, trade):
|
||||
"""
|
||||
成交变动推送
|
||||
:param trade: XtTrade对象
|
||||
:return:
|
||||
"""
|
||||
print(datetime.datetime.now(), '成交回调', trade.order_remark, f"委托方向(48买 49卖) {trade.offset_flag} 成交价格 {trade.traded_price} 成交数量 {trade.traded_volume}")
|
||||
|
||||
def on_order_error(self, order_error):
|
||||
"""
|
||||
委托失败推送
|
||||
:param order_error:XtOrderError 对象
|
||||
:return:
|
||||
"""
|
||||
# print("on order_error callback")
|
||||
# print(order_error.order_id, order_error.error_id, order_error.error_msg)
|
||||
print(f"委托报错回调 {order_error.order_remark} {order_error.error_msg}")
|
||||
|
||||
def on_cancel_error(self, cancel_error):
|
||||
"""
|
||||
撤单失败推送
|
||||
:param cancel_error: XtCancelError 对象
|
||||
:return:
|
||||
"""
|
||||
print(datetime.datetime.now(), sys._getframe().f_code.co_name)
|
||||
|
||||
def on_order_stock_async_response(self, response):
|
||||
"""
|
||||
异步下单回报推送
|
||||
:param response: XtOrderResponse 对象
|
||||
:return:
|
||||
"""
|
||||
print(f"异步委托回调 投资备注: {response.order_remark}")
|
||||
|
||||
def on_cancel_order_stock_async_response(self, response):
|
||||
"""
|
||||
:param response: XtCancelOrderResponse 对象
|
||||
:return:
|
||||
"""
|
||||
print(datetime.datetime.now(), sys._getframe().f_code.co_name)
|
||||
|
||||
def on_account_status(self, status):
|
||||
"""
|
||||
:param response: XtAccountStatus 对象
|
||||
:return:
|
||||
"""
|
||||
print(datetime.datetime.now(), sys._getframe().f_code.co_name)
|
||||
Reference in New Issue
Block a user