diff --git a/vnpy/event/__init__.py b/vnpy/event/__init__.py index 860852ad..b55e4294 100644 --- a/vnpy/event/__init__.py +++ b/vnpy/event/__init__.py @@ -1,3 +1,3 @@ # encoding: UTF-8 -from .eventEngine import EventEngine, EventEngine2, Event \ No newline at end of file +from .eventEngine import EventEngine, EventEngine2, Event, EVENT_TIMER \ No newline at end of file diff --git a/vnpy/event/eventEngine.py b/vnpy/event/eventEngine.py index a89c924e..fd0df469 100644 --- a/vnpy/event/eventEngine.py +++ b/vnpy/event/eventEngine.py @@ -1,7 +1,7 @@ # encoding: UTF-8 # 系统模块 -from Queue import Queue, Empty +from queue import Queue, Empty from threading import Thread from time import sleep from collections import defaultdict @@ -10,7 +10,7 @@ from collections import defaultdict from qtpy.QtCore import QTimer # 自己开发的模块 -from eventType import * +from .eventType import * ######################################################################## @@ -339,7 +339,7 @@ def test(): from PyQt4.QtCore import QCoreApplication def simpletest(event): - print u'处理每秒触发的计时器事件:%s' % str(datetime.now()) + print(u'处理每秒触发的计时器事件:{}'.format(str(datetime.now()))) app = QCoreApplication(sys.argv) diff --git a/vnpy/event/eventType.py b/vnpy/event/eventType.py index 8ce348e1..afe7ff72 100644 --- a/vnpy/event/eventType.py +++ b/vnpy/event/eventType.py @@ -32,12 +32,12 @@ def test(): for key, value in check_dict.items(): if len(value)>1: - print u'存在重复的常量定义:' + str(key) + print(u'存在重复的常量定义:{}'.format(str(key))) for name in value: print name print '' - print u'测试完毕' + print(u'测试完毕') # 直接运行脚本可以进行测试 diff --git a/vnpy/trader/app/ctaStrategy/__init__.py b/vnpy/trader/app/ctaStrategy/__init__.py index 7c1dbf6a..91579520 100644 --- a/vnpy/trader/app/ctaStrategy/__init__.py +++ b/vnpy/trader/app/ctaStrategy/__init__.py @@ -1,7 +1,7 @@ # encoding: UTF-8 -from ctaEngine import CtaEngine -from uiCtaWidget import CtaEngineManager +from .ctaEngine import CtaEngine +from .uiCtaWidget import CtaEngineManager appName = 'CtaStrategy' appDisplayName = u'CTA策略' diff --git a/vnpy/trader/app/ctaStrategy/ctaEngine.py b/vnpy/trader/app/ctaStrategy/ctaEngine.py index a13177c3..06f27034 100644 --- a/vnpy/trader/app/ctaStrategy/ctaEngine.py +++ b/vnpy/trader/app/ctaStrategy/ctaEngine.py @@ -385,8 +385,9 @@ class CtaEngine(object): try: name = setting['name'] className = setting['className'] - except Exception, e: - self.writeCtaLog(u'载入策略出错:%s' %e) + except Exception: + msg = traceback.format_exc() + self.writeCtaLog(u'载入策略出错:%s' %msg) return # 获取策略类 diff --git a/vnpy/trader/app/ctaStrategy/strategy/__init__.py b/vnpy/trader/app/ctaStrategy/strategy/__init__.py index 63daa733..cdf0cb1a 100644 --- a/vnpy/trader/app/ctaStrategy/strategy/__init__.py +++ b/vnpy/trader/app/ctaStrategy/strategy/__init__.py @@ -23,7 +23,7 @@ def loadStrategyModule(moduleName): v = module.__getattribute__(k) STRATEGY_CLASS[k] = v except: - print '-' * 20 + print ('-' * 20) print ('Failed to import strategy file %s:' %moduleName) traceback.print_exc() diff --git a/vnpy/trader/language/__init__.py b/vnpy/trader/language/__init__.py index 7924c2c1..1f6f22cd 100644 --- a/vnpy/trader/language/__init__.py +++ b/vnpy/trader/language/__init__.py @@ -4,9 +4,9 @@ import json import os # 默认设置 -from chinese import text, constant +from .chinese import text, constant # 是否要使用英文 from vnpy.trader.vtGlobal import globalSetting if globalSetting['language'] == 'english': - from english import text, constant \ No newline at end of file + from .english import text, constant \ No newline at end of file diff --git a/vnpy/trader/vtGlobal.py b/vnpy/trader/vtGlobal.py index f5a3761f..25581335 100644 --- a/vnpy/trader/vtGlobal.py +++ b/vnpy/trader/vtGlobal.py @@ -7,7 +7,7 @@ import os import traceback import json -from vtFunction import getJsonPath +from .vtFunction import getJsonPath settingFileName = "VT_setting.json" @@ -16,8 +16,11 @@ settingFilePath = getJsonPath(settingFileName, __file__) globalSetting = {} # 全局配置字典 try: - f = file(settingFilePath) - globalSetting = json.load(f) + with open(settingFilePath) as f: + setting = f.read() + if type(setting) is not str: + setting = str(setting, encoding='utf8') + globalSetting = json.loads(setting) except: traceback.print_exc()