From e34c58fa3814bee4076a4624ef678f70ca42b6fc Mon Sep 17 00:00:00 2001 From: msincenselee Date: Sun, 18 Jun 2017 00:57:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BC=82=E5=B8=B8=E3=80=81?= =?UTF-8?q?=E5=91=8A=E8=AD=A6=E7=AD=89=E6=97=A5=E5=BF=97=E5=A4=84=E7=90=86?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/trader/app/ctaStrategy/ctaEngine.py | 27 +++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/vnpy/trader/app/ctaStrategy/ctaEngine.py b/vnpy/trader/app/ctaStrategy/ctaEngine.py index ce0f1421..4f17ac26 100644 --- a/vnpy/trader/app/ctaStrategy/ctaEngine.py +++ b/vnpy/trader/app/ctaStrategy/ctaEngine.py @@ -580,7 +580,23 @@ class CtaEngine(object): # 写入本地log日志 logging.info(content) - + + def writeCtaError(self,content): + """快速发出CTA模块错误日志事件""" + self.mainEngine.writeError(content) + + def writeCtaWarning(self, content): + """快速发出CTA模块告警日志事件""" + self.mainEngine.writeWarning(content) + + def writeCtaNotification(self, content): + """快速发出CTA模块通知事件""" + self.mainEngine.writeNotification(content) + + def writeCtaCritical(self,content): + """快速发出CTA模块异常日志事件""" + self.mainEngine.writeCritical(content) + # ---------------------------------------------------------------------- def loadStrategy(self, setting): """载入策略""" @@ -589,12 +605,14 @@ class CtaEngine(object): className = setting['className'] except Exception as e: self.writeCtaLog(u'载入策略出错:%s' %e) + self.mainEngine.writeCritical(u'载入策略出错:%s' %e) return # 获取策略类 strategyClass = STRATEGY_CLASS.get(className, None) if not strategyClass: - self.writeCtaLog(u'找不到策略类:%s' %className) + self.writeCtaLog(u'STRATEGY_CLASS找不到策略类:%s' %className) + self.mainEngine.writeCritical(u'STRATEGY_CLASS找不到策略类:%s' %className) return # 防止策略重名 @@ -744,7 +762,7 @@ class CtaEngine(object): if so.strategy is strategy: self.cancelStopOrder(stopOrderID) else: - self.writeCtaLog(u'策略实例不存在:%s' %name) + self.writeCtaLog(u'策略实例不存在:%s' %name) # ---------------------------------------------------------------------- def saveSetting(self): @@ -811,6 +829,8 @@ class CtaEngine(object): def putStrategyEvent(self, name): """触发策略状态变化事件(通常用于通知GUI更新)""" event = Event(EVENT_CTA_STRATEGY+name) + d = 'putevent' + event.dict_['data'] = d self.eventEngine.put(event) # ---------------------------------------------------------------------- @@ -830,6 +850,7 @@ class CtaEngine(object): content = '\n'.join([u'策略%s触发异常已停止' % strategy.name, traceback.format_exc()]) self.writeCtaLog(content) + self.mainEngine.writeCritical(content) # ---------------------------------------------------------------------- def savePosition(self):