def on_order_stock_async_response(self, response):
"""
异步下单回报推送
:param response: XtOrderResponse 对象
:return:
"""
print("on_order_stock_async_response")
print(response.account_id, response.order_id, response.seq)
def order_stock_async(self, account, stock_code, order_type, order_volume, price_type, price, strategy_name='',
order_remark=''):
"""
:param account: 证券账号
:param stock_code: 证券代码, 例如"600000.SH"
:param order_type: 委托类型, 23:买, 24:卖
:param order_volume: 委托数量, 股票以'股'为单位, 债券以'张'为单位
:param price_type: 报价类型, 详见帮助手册
:param price: 报价价格, 如果price_type为指定价, 那price为指定的价格, 否则填0
:param strategy_name: 策略名称
:param order_remark: 委托备注
:return: 返回下单请求序号, 成功委托后的下单请求序号为大于0的正整数, 如果为-1表示委托失败
"""
req = _XTQC_.OrderStockReq()
req.m_nAccountType = account.account_type
req.m_strAccountID = account.account_id
req.m_strStockCode = stock_code
req.m_nOrderType = order_type
req.m_nOrderVolume = int(order_volume)
req.m_nPriceType = price_type
req.m_dPrice = price
req.m_strStrategyName = strategy_name
req.m_strOrderRemark = order_remark
req.m_strOrderRemarkNew = order_remark
req.m_dOrderAmount = order_volume
req.m_strStockCode1 = stock_code
seq = self.async_client.nextSeq()
self.queuing_order_seq.add(seq)
self.cbs[seq] = self.callback.on_order_stock_async_response
self.async_client.orderStockWithSeq(seq, req)
return seq
有2个困扰,希望可以解决:
1、on_order_stock_async_response异步下单回报推送,有(account_id,account_type,error_msg,order_id,order_remark,seq,strategy_name)这些属性,缺少股票代码、交易方向、交易股数 等信息,我用来写量化程序的时候会用到这几个信息,很困扰我,于是我就把交易方向和交易股数 信息放到了order_remark里面进行传递。
2、又遇到order_stock_async函数 order_remark 限制19个字符串的问题,传递超过19个字符串,on_order_stock_async_response 的 order_remark 会自动截断成前19个字符串。
|