diff --git a/vn.trader/ibGateway/ibGateway.py b/vn.trader/ibGateway/ibGateway.py index 036d907b..ad832bda 100644 --- a/vn.trader/ibGateway/ibGateway.py +++ b/vn.trader/ibGateway/ibGateway.py @@ -11,6 +11,7 @@ ibpy的gateway接入 5. 海外市场的交易规则和国内有很多细节上的不同,所以一些字段类型的映射可能不合理,如果发现问题欢迎指出 ''' +import os import json from time import sleep, strftime, localtime from copy import copy @@ -607,4 +608,4 @@ class IbWrapper(EWrapper): log.logContent = (u'IB接口连接断开') self.gateway.onLog(log) - \ No newline at end of file + diff --git a/vn.trader/vtFunction.py b/vn.trader/vtFunction.py index c752708e..8ad23936 100644 --- a/vn.trader/vtFunction.py +++ b/vn.trader/vtFunction.py @@ -6,6 +6,7 @@ import decimal import json +import sys MAX_NUMBER = 10000000000000 MAX_DECIMAL = 4 @@ -24,6 +25,9 @@ def safeUnicode(value): if abs(d.as_tuple().exponent) > MAX_DECIMAL: value = round(value, ndigits=MAX_DECIMAL) + # Reload sys, Set default encode to UTF8 + reload(sys) + sys.setdefaultencoding('utf8') return unicode(value) #---------------------------------------------------------------------- @@ -40,4 +44,4 @@ def loadMongoSetting(): return host, port - \ No newline at end of file + diff --git a/vn.trader/vtMain.py b/vn.trader/vtMain.py index 35e094b8..d0c909e0 100644 --- a/vn.trader/vtMain.py +++ b/vn.trader/vtMain.py @@ -2,6 +2,7 @@ import sys import ctypes +import platform from vtEngine import MainEngine from uiMainWindow import * @@ -10,7 +11,8 @@ from uiMainWindow import * def main(): """主程序入口""" # 设置底部任务栏图标,win7以下请注释掉 - ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID('vn.py demo') + if platform.uname() == 'Windows': + ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID('vn.py demo') # 初始化Qt应用对象 app = QtGui.QApplication(sys.argv)