[Fix]修复手动交易组件的Tick更新机制bug

This commit is contained in:
vn.py 2018-03-28 13:02:04 +08:00
parent fe636ade04
commit 90f535d5cb

View File

@ -721,7 +721,7 @@ class TradingWidget(QtWidgets.QFrame):
self.gatewayList.extend(gatewayNameList) self.gatewayList.extend(gatewayNameList)
self.initUi() self.initUi()
self.connectSignal() self.registerEvent()
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def initUi(self): def initUi(self):
@ -961,10 +961,6 @@ class TradingWidget(QtWidgets.QFrame):
self.labelLastPrice.setText('') self.labelLastPrice.setText('')
self.labelReturn.setText('') self.labelReturn.setText('')
# 重新注册事件监听
self.eventEngine.unregister(EVENT_TICK + self.symbol, self.signal.emit)
self.eventEngine.register(EVENT_TICK + vtSymbol, self.signal.emit)
# 订阅合约 # 订阅合约
req = VtSubscribeReq() req = VtSubscribeReq()
req.symbol = symbol req.symbol = symbol
@ -984,48 +980,51 @@ class TradingWidget(QtWidgets.QFrame):
def updateTick(self, event): def updateTick(self, event):
"""更新行情""" """更新行情"""
tick = event.dict_['data'] tick = event.dict_['data']
if tick.vtSymbol != self.symbol:
return
if tick.vtSymbol == self.symbol: if not self.checkFixed.isChecked():
if not self.checkFixed.isChecked(): self.spinPrice.setValue(tick.lastPrice)
self.spinPrice.setValue(tick.lastPrice)
self.labelBidPrice1.setText(str(tick.bidPrice1))
self.labelAskPrice1.setText(str(tick.askPrice1))
self.labelBidVolume1.setText(str(tick.bidVolume1))
self.labelAskVolume1.setText(str(tick.askVolume1))
if tick.bidPrice2: self.labelBidPrice1.setText(str(tick.bidPrice1))
self.labelBidPrice2.setText(str(tick.bidPrice2)) self.labelAskPrice1.setText(str(tick.askPrice1))
self.labelBidPrice3.setText(str(tick.bidPrice3)) self.labelBidVolume1.setText(str(tick.bidVolume1))
self.labelBidPrice4.setText(str(tick.bidPrice4)) self.labelAskVolume1.setText(str(tick.askVolume1))
self.labelBidPrice5.setText(str(tick.bidPrice5))
self.labelAskPrice2.setText(str(tick.askPrice2)) if tick.bidPrice2:
self.labelAskPrice3.setText(str(tick.askPrice3)) self.labelBidPrice2.setText(str(tick.bidPrice2))
self.labelAskPrice4.setText(str(tick.askPrice4)) self.labelBidPrice3.setText(str(tick.bidPrice3))
self.labelAskPrice5.setText(str(tick.askPrice5)) self.labelBidPrice4.setText(str(tick.bidPrice4))
self.labelBidPrice5.setText(str(tick.bidPrice5))
self.labelBidVolume2.setText(str(tick.bidVolume2)) self.labelAskPrice2.setText(str(tick.askPrice2))
self.labelBidVolume3.setText(str(tick.bidVolume3)) self.labelAskPrice3.setText(str(tick.askPrice3))
self.labelBidVolume4.setText(str(tick.bidVolume4)) self.labelAskPrice4.setText(str(tick.askPrice4))
self.labelBidVolume5.setText(str(tick.bidVolume5)) self.labelAskPrice5.setText(str(tick.askPrice5))
self.labelAskVolume2.setText(str(tick.askVolume2)) self.labelBidVolume2.setText(str(tick.bidVolume2))
self.labelAskVolume3.setText(str(tick.askVolume3)) self.labelBidVolume3.setText(str(tick.bidVolume3))
self.labelAskVolume4.setText(str(tick.askVolume4)) self.labelBidVolume4.setText(str(tick.bidVolume4))
self.labelAskVolume5.setText(str(tick.askVolume5)) self.labelBidVolume5.setText(str(tick.bidVolume5))
self.labelLastPrice.setText(str(tick.lastPrice)) self.labelAskVolume2.setText(str(tick.askVolume2))
self.labelAskVolume3.setText(str(tick.askVolume3))
self.labelAskVolume4.setText(str(tick.askVolume4))
self.labelAskVolume5.setText(str(tick.askVolume5))
if tick.preClosePrice: self.labelLastPrice.setText(str(tick.lastPrice))
rt = (tick.lastPrice/tick.preClosePrice)-1
self.labelReturn.setText(('%.2f' %(rt*100))+'%') if tick.preClosePrice:
else: rt = (tick.lastPrice/tick.preClosePrice)-1
self.labelReturn.setText('') self.labelReturn.setText(('%.2f' %(rt*100))+'%')
else:
self.labelReturn.setText('')
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def connectSignal(self): def registerEvent(self):
"""连接Signal""" """注册事件监听"""
self.signal.connect(self.updateTick) self.signal.connect(self.updateTick)
self.eventEngine.register(EVENT_TICK, self.signal.emit)
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def sendOrder(self): def sendOrder(self):