[Mod]将CTA监控组件的参数更新数据来源改为推送

This commit is contained in:
vn.py 2018-01-21 14:08:14 +08:00
parent 56c9fdcda5
commit 73a69e8785
3 changed files with 13 additions and 4 deletions

View File

@ -1,4 +1,4 @@
# encoding: UTF-8
__version__ = '1.7.2'
__version__ = '1.7.3'
__author__ = 'Xiaoyou Chen'

View File

@ -559,7 +559,10 @@ class CtaEngine(object):
#----------------------------------------------------------------------
def putStrategyEvent(self, name):
"""触发策略状态变化事件通常用于通知GUI更新"""
strategy = self.strategyDict[name]
d = {k:strategy.__getattribute__(k) for k in strategy.varList}
event = Event(EVENT_CTA_STRATEGY+name)
event.dict_['data'] = d
self.eventEngine.put(event)
#----------------------------------------------------------------------

View File

@ -115,7 +115,7 @@ class CtaStrategyManager(QtWidgets.QGroupBox):
self.setLayout(vbox)
#----------------------------------------------------------------------
def updateMonitor(self, event=None):
def updateMonitor(self):
"""显示策略最新状态"""
paramDict = self.ctaEngine.getStrategyParam(self.name)
if paramDict:
@ -124,11 +124,17 @@ class CtaStrategyManager(QtWidgets.QGroupBox):
varDict = self.ctaEngine.getStrategyVar(self.name)
if varDict:
self.varMonitor.updateData(varDict)
#----------------------------------------------------------------------
def updateVar(self, event):
"""更新策略变量"""
data = event.dict_['data']
self.varMonitor.updateData(data)
#----------------------------------------------------------------------
def registerEvent(self):
"""注册事件监听"""
self.signal.connect(self.updateMonitor)
self.signal.connect(self.updateVar)
self.eventEngine.register(EVENT_CTA_STRATEGY+self.name, self.signal.emit)
#----------------------------------------------------------------------