From 24b0ddfbb7cfab4e7f634cfc6925af32f10b4229 Mon Sep 17 00:00:00 2001 From: Bian Jiang Date: Fri, 29 Apr 2016 07:47:29 +0800 Subject: [PATCH 1/2] =?UTF-8?q?1.=20=E4=BF=AE=E5=A4=8DIB=E6=8A=A5=E9=94=99?= =?UTF-8?q?=202.=20=E4=BF=AE=E5=A4=8D=E5=9C=A8MAC=E4=B8=8A=E7=BC=96?= =?UTF-8?q?=E7=A0=81=E9=94=99=E8=AF=AF,=20=E9=BB=98=E8=AE=A4=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E4=BD=8DUTF8=203.=20=E8=AE=BE=E7=BD=AE=E5=BA=95?= =?UTF-8?q?=E9=83=A8=E4=BB=BB=E5=8A=A1=E6=A0=8F=E5=9B=BE=E6=A0=87=E5=8F=AA?= =?UTF-8?q?=E5=9C=A8windows=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vn.trader/ibGateway/ibGateway.py | 3 ++- vn.trader/vtFunction.py | 6 +++++- vn.trader/vtMain.py | 4 +++- 3 files changed, 10 insertions(+), 3 deletions(-) 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) From 02d1735bb116f3a889244c5ffb44050f6e52eeb7 Mon Sep 17 00:00:00 2001 From: Bian Jiang Date: Fri, 29 Apr 2016 13:42:29 +0800 Subject: [PATCH 2/2] fix vtFunction --- vn.trader/vtFunction.py | 4 ---- vn.trader/vtMain.py | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/vn.trader/vtFunction.py b/vn.trader/vtFunction.py index 8ad23936..708de59e 100644 --- a/vn.trader/vtFunction.py +++ b/vn.trader/vtFunction.py @@ -6,7 +6,6 @@ import decimal import json -import sys MAX_NUMBER = 10000000000000 MAX_DECIMAL = 4 @@ -25,9 +24,6 @@ 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) #---------------------------------------------------------------------- diff --git a/vn.trader/vtMain.py b/vn.trader/vtMain.py index d0c909e0..554b1fd7 100644 --- a/vn.trader/vtMain.py +++ b/vn.trader/vtMain.py @@ -14,6 +14,10 @@ def main(): if platform.uname() == 'Windows': ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID('vn.py demo') + # Reload sys, Set default encode to UTF8 + reload(sys) + sys.setdefaultencoding('utf8') + # 初始化Qt应用对象 app = QtGui.QApplication(sys.argv) app.setWindowIcon(QtGui.QIcon('vnpy.ico'))