[Mod]增加富途接口订阅本日所有委托推送的功能

This commit is contained in:
vn.py 2017-10-24 10:52:02 +08:00
parent 6a2b12420d
commit 440bd2812f

View File

@ -201,8 +201,8 @@ class FutuGateway(VtGateway):
return RET_OK, content return RET_OK, content
# 只有港股实盘交易才需要解锁 # 只有港股实盘交易才需要解锁
if self.market == 'HK' and self.env == 0: if self.market == 'HK' and self.env == 0:
self.tradeCtx.unlock_trade(self.password) self.tradeCtx.unlock_trade(self.password)
# 设置回调处理对象 # 设置回调处理对象
self.tradeCtx.set_handler(OrderHandler()) self.tradeCtx.set_handler(OrderHandler())
@ -231,7 +231,7 @@ class FutuGateway(VtGateway):
code, data = self.tradeCtx.place_order(orderReq.price, orderReq.volume, code, data = self.tradeCtx.place_order(orderReq.price, orderReq.volume,
orderReq.symbol, side, orderReq.symbol, side,
priceType, self.env, priceType, self.env,
orderpush=True, dealpush=True) order_deal_push=True)
if code: if code:
self.writeError(code, u'委托失败:%s' %data) self.writeError(code, u'委托失败:%s' %data)
@ -303,7 +303,7 @@ class FutuGateway(VtGateway):
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def qryPosition(self): def qryPosition(self):
"""查询持仓""" """查询持仓"""
code, data = self.tradeCtx.position_list_query(self.env) code, data = self.tradeCtx.position_list_query(envtype=self.env)
if code: if code:
self.writeError(code, u'查询持仓失败:%s' %data) self.writeError(code, u'查询持仓失败:%s' %data)
@ -329,13 +329,13 @@ class FutuGateway(VtGateway):
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def qryOrder(self): def qryOrder(self):
"""查询委托""" """查询委托"""
code, data = self.tradeCtx.order_list_query("", self.env) code, data = self.tradeCtx.order_list_query("", envtype=self.env)
if code: if code:
self.writeError(code, u'查询委托失败:%s' %data) self.writeError(code, u'查询委托失败:%s' %data)
return return
self.processOrder(data) self.processOrder(data, qry=True)
self.writeLog(u'委托查询成功') self.writeLog(u'委托查询成功')
#---------------------------------------------------------------------- #----------------------------------------------------------------------
@ -453,7 +453,7 @@ class FutuGateway(VtGateway):
self.onTick(tick) self.onTick(tick)
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def processOrder(self, data): def processOrder(self, data, qry=False):
"""处理委托推送""" """处理委托推送"""
for ix, row in data.iterrows(): for ix, row in data.iterrows():
order = VtOrderData() order = VtOrderData()
@ -475,6 +475,11 @@ class FutuGateway(VtGateway):
order.status = statusMapReverse.get(str(row['status']), STATUS_UNKNOWN) order.status = statusMapReverse.get(str(row['status']), STATUS_UNKNOWN)
order.direction = directionMapReverse[str(row['order_side'])] order.direction = directionMapReverse[str(row['order_side'])]
self.onOrder(order) self.onOrder(order)
if qry:
self.tradeCtx.subscribe_order_deal_push(row['orderid'],
order_deal_push=True,
envtype=self.env)
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def processDeal(self, data): def processDeal(self, data):