[Mod]部分代码向3风格兼容修改
This commit is contained in:
parent
64bd2eb6d2
commit
b2aa6c5c2b
@ -1,3 +1,3 @@
|
|||||||
# encoding: UTF-8
|
# encoding: UTF-8
|
||||||
|
|
||||||
from .eventEngine import EventEngine, EventEngine2, Event
|
from .eventEngine import EventEngine, EventEngine2, Event, EVENT_TIMER
|
@ -1,7 +1,7 @@
|
|||||||
# encoding: UTF-8
|
# encoding: UTF-8
|
||||||
|
|
||||||
# 系统模块
|
# 系统模块
|
||||||
from Queue import Queue, Empty
|
from queue import Queue, Empty
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
@ -10,7 +10,7 @@ from collections import defaultdict
|
|||||||
from qtpy.QtCore import QTimer
|
from qtpy.QtCore import QTimer
|
||||||
|
|
||||||
# 自己开发的模块
|
# 自己开发的模块
|
||||||
from eventType import *
|
from .eventType import *
|
||||||
|
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
@ -339,7 +339,7 @@ def test():
|
|||||||
from PyQt4.QtCore import QCoreApplication
|
from PyQt4.QtCore import QCoreApplication
|
||||||
|
|
||||||
def simpletest(event):
|
def simpletest(event):
|
||||||
print u'处理每秒触发的计时器事件:%s' % str(datetime.now())
|
print(u'处理每秒触发的计时器事件:{}'.format(str(datetime.now())))
|
||||||
|
|
||||||
app = QCoreApplication(sys.argv)
|
app = QCoreApplication(sys.argv)
|
||||||
|
|
||||||
|
@ -32,12 +32,12 @@ def test():
|
|||||||
|
|
||||||
for key, value in check_dict.items():
|
for key, value in check_dict.items():
|
||||||
if len(value)>1:
|
if len(value)>1:
|
||||||
print u'存在重复的常量定义:' + str(key)
|
print(u'存在重复的常量定义:{}'.format(str(key)))
|
||||||
for name in value:
|
for name in value:
|
||||||
print name
|
print name
|
||||||
print ''
|
print ''
|
||||||
|
|
||||||
print u'测试完毕'
|
print(u'测试完毕')
|
||||||
|
|
||||||
|
|
||||||
# 直接运行脚本可以进行测试
|
# 直接运行脚本可以进行测试
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# encoding: UTF-8
|
# encoding: UTF-8
|
||||||
|
|
||||||
from ctaEngine import CtaEngine
|
from .ctaEngine import CtaEngine
|
||||||
from uiCtaWidget import CtaEngineManager
|
from .uiCtaWidget import CtaEngineManager
|
||||||
|
|
||||||
appName = 'CtaStrategy'
|
appName = 'CtaStrategy'
|
||||||
appDisplayName = u'CTA策略'
|
appDisplayName = u'CTA策略'
|
||||||
|
@ -385,8 +385,9 @@ class CtaEngine(object):
|
|||||||
try:
|
try:
|
||||||
name = setting['name']
|
name = setting['name']
|
||||||
className = setting['className']
|
className = setting['className']
|
||||||
except Exception, e:
|
except Exception:
|
||||||
self.writeCtaLog(u'载入策略出错:%s' %e)
|
msg = traceback.format_exc()
|
||||||
|
self.writeCtaLog(u'载入策略出错:%s' %msg)
|
||||||
return
|
return
|
||||||
|
|
||||||
# 获取策略类
|
# 获取策略类
|
||||||
|
@ -23,7 +23,7 @@ def loadStrategyModule(moduleName):
|
|||||||
v = module.__getattribute__(k)
|
v = module.__getattribute__(k)
|
||||||
STRATEGY_CLASS[k] = v
|
STRATEGY_CLASS[k] = v
|
||||||
except:
|
except:
|
||||||
print '-' * 20
|
print ('-' * 20)
|
||||||
print ('Failed to import strategy file %s:' %moduleName)
|
print ('Failed to import strategy file %s:' %moduleName)
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
|
@ -4,9 +4,9 @@ import json
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
# 默认设置
|
# 默认设置
|
||||||
from chinese import text, constant
|
from .chinese import text, constant
|
||||||
|
|
||||||
# 是否要使用英文
|
# 是否要使用英文
|
||||||
from vnpy.trader.vtGlobal import globalSetting
|
from vnpy.trader.vtGlobal import globalSetting
|
||||||
if globalSetting['language'] == 'english':
|
if globalSetting['language'] == 'english':
|
||||||
from english import text, constant
|
from .english import text, constant
|
@ -7,7 +7,7 @@
|
|||||||
import os
|
import os
|
||||||
import traceback
|
import traceback
|
||||||
import json
|
import json
|
||||||
from vtFunction import getJsonPath
|
from .vtFunction import getJsonPath
|
||||||
|
|
||||||
|
|
||||||
settingFileName = "VT_setting.json"
|
settingFileName = "VT_setting.json"
|
||||||
@ -16,8 +16,11 @@ settingFilePath = getJsonPath(settingFileName, __file__)
|
|||||||
globalSetting = {} # 全局配置字典
|
globalSetting = {} # 全局配置字典
|
||||||
|
|
||||||
try:
|
try:
|
||||||
f = file(settingFilePath)
|
with open(settingFilePath) as f:
|
||||||
globalSetting = json.load(f)
|
setting = f.read()
|
||||||
|
if type(setting) is not str:
|
||||||
|
setting = str(setting, encoding='utf8')
|
||||||
|
globalSetting = json.loads(setting)
|
||||||
except:
|
except:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user