diff --git a/vnpy/trader/app/ctaStrategy/__init__.py b/vnpy/trader/app/ctaStrategy/__init__.py index 0d56f7c5..7c1dbf6a 100644 --- a/vnpy/trader/app/ctaStrategy/__init__.py +++ b/vnpy/trader/app/ctaStrategy/__init__.py @@ -6,4 +6,5 @@ from uiCtaWidget import CtaEngineManager appName = 'CtaStrategy' appDisplayName = u'CTA策略' appEngine = CtaEngine -appWidget = CtaEngineManager \ No newline at end of file +appWidget = CtaEngineManager +appIco = 'cta.ico' \ No newline at end of file diff --git a/vnpy/trader/app/ctaStrategy/cta.ico b/vnpy/trader/app/ctaStrategy/cta.ico new file mode 100644 index 00000000..25cbaa73 Binary files /dev/null and b/vnpy/trader/app/ctaStrategy/cta.ico differ diff --git a/vnpy/trader/app/ctaStrategy/ctaEngine.py b/vnpy/trader/app/ctaStrategy/ctaEngine.py index 9a24a61b..2a2178b5 100644 --- a/vnpy/trader/app/ctaStrategy/ctaEngine.py +++ b/vnpy/trader/app/ctaStrategy/ctaEngine.py @@ -35,6 +35,8 @@ from vnpy.trader.app.ctaStrategy.ctaBase import * from vnpy.trader.app.ctaStrategy.strategy import STRATEGY_CLASS + + ######################################################################## class CtaEngine(object): """CTA策略引擎""" diff --git a/vnpy/trader/app/dataRecorder/__init__.py b/vnpy/trader/app/dataRecorder/__init__.py index aa9f55e0..84020dfe 100644 --- a/vnpy/trader/app/dataRecorder/__init__.py +++ b/vnpy/trader/app/dataRecorder/__init__.py @@ -6,4 +6,5 @@ from uiDrWidget import DrEngineManager appName = 'DataRecorder' appDisplayName = u'行情记录' appEngine = DrEngine -appWidget = DrEngineManager \ No newline at end of file +appWidget = DrEngineManager +appIco = 'dr.ico' \ No newline at end of file diff --git a/vnpy/trader/app/dataRecorder/dr.ico b/vnpy/trader/app/dataRecorder/dr.ico new file mode 100644 index 00000000..1ddc8b85 Binary files /dev/null and b/vnpy/trader/app/dataRecorder/dr.ico differ diff --git a/vnpy/trader/app/riskManager/__init__.py b/vnpy/trader/app/riskManager/__init__.py index 4ace680d..c58c8c61 100644 --- a/vnpy/trader/app/riskManager/__init__.py +++ b/vnpy/trader/app/riskManager/__init__.py @@ -6,4 +6,5 @@ from uiRmWidget import RmEngineManager appName = 'RiskManager' appDisplayName = u'风险管理' appEngine = RmEngine -appWidget = RmEngineManager \ No newline at end of file +appWidget = RmEngineManager +appIco = 'rm.ico' \ No newline at end of file diff --git a/vnpy/trader/app/riskManager/rm.ico b/vnpy/trader/app/riskManager/rm.ico new file mode 100644 index 00000000..4b376934 Binary files /dev/null and b/vnpy/trader/app/riskManager/rm.ico differ diff --git a/vnpy/trader/archive/app.ico b/vnpy/trader/archive/app.ico new file mode 100644 index 00000000..152292aa Binary files /dev/null and b/vnpy/trader/archive/app.ico differ diff --git a/vnpy/trader/archive/help.ico b/vnpy/trader/archive/help.ico new file mode 100644 index 00000000..2cff09c9 Binary files /dev/null and b/vnpy/trader/archive/help.ico differ diff --git a/vnpy/trader/archive/system.ico b/vnpy/trader/archive/system.ico new file mode 100644 index 00000000..0b23e1b3 Binary files /dev/null and b/vnpy/trader/archive/system.ico differ diff --git a/vnpy/trader/gateway/ctpGateway/CTP_connect.json b/vnpy/trader/gateway/ctpGateway/CTP_connect.json index 1b4d5a42..e4bfa6b8 100644 --- a/vnpy/trader/gateway/ctpGateway/CTP_connect.json +++ b/vnpy/trader/gateway/ctpGateway/CTP_connect.json @@ -2,6 +2,6 @@ "brokerID": "9999", "mdAddress": "tcp://180.168.146.187:10011", "tdAddress": "tcp://180.168.146.187:10001", - "userID": "000300", - "password": "19890624" + "userID": "simnow申请", + "password": "simnow申请" } \ No newline at end of file diff --git a/vnpy/trader/ico/about.ico b/vnpy/trader/ico/about.ico new file mode 100644 index 00000000..10686551 Binary files /dev/null and b/vnpy/trader/ico/about.ico differ diff --git a/vnpy/trader/ico/connect.ico b/vnpy/trader/ico/connect.ico new file mode 100644 index 00000000..ad638cb4 Binary files /dev/null and b/vnpy/trader/ico/connect.ico differ diff --git a/vnpy/trader/ico/contract.ico b/vnpy/trader/ico/contract.ico new file mode 100644 index 00000000..3f4142a2 Binary files /dev/null and b/vnpy/trader/ico/contract.ico differ diff --git a/vnpy/trader/ico/database.ico b/vnpy/trader/ico/database.ico new file mode 100644 index 00000000..6ad2845e Binary files /dev/null and b/vnpy/trader/ico/database.ico differ diff --git a/vnpy/trader/ico/exit.ico b/vnpy/trader/ico/exit.ico new file mode 100644 index 00000000..1ca8be52 Binary files /dev/null and b/vnpy/trader/ico/exit.ico differ diff --git a/vnpy/trader/ico/restore.ico b/vnpy/trader/ico/restore.ico new file mode 100644 index 00000000..be9c6175 Binary files /dev/null and b/vnpy/trader/ico/restore.ico differ diff --git a/vnpy/trader/ico/test.ico b/vnpy/trader/ico/test.ico new file mode 100644 index 00000000..d0492b12 Binary files /dev/null and b/vnpy/trader/ico/test.ico differ diff --git a/vnpy/trader/vnpy.ico b/vnpy/trader/ico/vnpy.ico similarity index 100% rename from vnpy/trader/vnpy.ico rename to vnpy/trader/ico/vnpy.ico diff --git a/vnpy/trader/uiMainWindow.py b/vnpy/trader/uiMainWindow.py index 4b03e4d7..c49e8234 100644 --- a/vnpy/trader/uiMainWindow.py +++ b/vnpy/trader/uiMainWindow.py @@ -2,6 +2,7 @@ import psutil +from vnpy.trader.vtFunction import loadIconPath from vnpy.trader.vtGlobal import globalSetting from vnpy.trader.uiBasicWidget import * @@ -100,34 +101,26 @@ class MainWindow(QtWidgets.QMainWindow): self.addConnectAction(sysMenu, d['gatewayName'], d['gatewayDisplayName']) sysMenu.addSeparator() - sysMenu.addAction(self.createAction(vtText.CONNECT_DATABASE, self.mainEngine.dbConnect)) + sysMenu.addAction(self.createAction(vtText.CONNECT_DATABASE, self.mainEngine.dbConnect, loadIconPath('database.ico'))) sysMenu.addSeparator() - sysMenu.addAction(self.createAction(vtText.EXIT, self.close)) + sysMenu.addAction(self.createAction(vtText.EXIT, self.close, loadIconPath('exit.ico'))) # 功能应用 - #functionMenu = menubar.addMenu(vtText.APPLICATION) - #functionMenu.addAction(self.createAction(vtText.DATA_RECORDER, self.openDr)) - #functionMenu.addAction(self.createAction(vtText.RISK_MANAGER, self.openRm)) - appMenu = menubar.addMenu(vtText.APPLICATION) for appDetail in self.appDetailList: function = self.createOpenAppFunction(appDetail) - action = self.createAction(appDetail['appDisplayName'], function) + action = self.createAction(appDetail['appDisplayName'], function, loadIconPath(appDetail['appIco'])) appMenu.addAction(action) - # 算法相关 - #strategyMenu = menubar.addMenu(vtText.STRATEGY) - #strategyMenu.addAction(self.createAction(vtText.CTA_STRATEGY, self.openCta)) - # 帮助 helpMenu = menubar.addMenu(vtText.HELP) - helpMenu.addAction(self.createAction(vtText.CONTRACT_SEARCH, self.openContract)) + helpMenu.addAction(self.createAction(vtText.CONTRACT_SEARCH, self.openContract, loadIconPath('contract.ico'))) helpMenu.addSeparator() - helpMenu.addAction(self.createAction(vtText.RESTORE, self.restoreWindow)) - helpMenu.addAction(self.createAction(vtText.ABOUT, self.openAbout)) + helpMenu.addAction(self.createAction(vtText.RESTORE, self.restoreWindow, loadIconPath('restore.ico'))) + helpMenu.addAction(self.createAction(vtText.ABOUT, self.openAbout, loadIconPath('about.ico'))) helpMenu.addSeparator() - helpMenu.addAction(self.createAction(vtText.TEST, self.test)) + helpMenu.addAction(self.createAction(vtText.TEST, self.test, loadIconPath('test.ico'))) #---------------------------------------------------------------------- def initStatusBar(self): @@ -172,14 +165,20 @@ class MainWindow(QtWidgets.QMainWindow): displayName = gatewayName actionName = vtText.CONNECT + displayName - - menu.addAction(self.createAction(actionName, connect)) + connectAction = self.createAction(actionName, connect, + loadIconPath('connect.ico')) + menu.addAction(connectAction) #---------------------------------------------------------------------- - def createAction(self, actionName, function): + def createAction(self, actionName, function, iconPath=''): """创建操作功能""" action = QtWidgets.QAction(actionName, self) action.triggered.connect(function) + + if iconPath: + icon = QtGui.QIcon(iconPath) + action.setIcon(icon) + return action #---------------------------------------------------------------------- diff --git a/vnpy/trader/uiQt.py b/vnpy/trader/uiQt.py index be94b4ce..c8ca4f0c 100644 --- a/vnpy/trader/uiQt.py +++ b/vnpy/trader/uiQt.py @@ -33,4 +33,4 @@ except: qApp.setFont(BASIC_FONT) # 设置Qt图标 -qApp.setWindowIcon(QtGui.QIcon(loadIconPath())) \ No newline at end of file +qApp.setWindowIcon(QtGui.QIcon(loadIconPath('vnpy.ico'))) \ No newline at end of file diff --git a/vnpy/trader/vtEngine.py b/vnpy/trader/vtEngine.py index 108dd6be..b8bc63dc 100644 --- a/vnpy/trader/vtEngine.py +++ b/vnpy/trader/vtEngine.py @@ -78,7 +78,8 @@ class MainEngine(object): d = { 'appName': appModule.appName, 'appDisplayName': appModule.appDisplayName, - 'appWidget': appModule.appWidget + 'appWidget': appModule.appWidget, + 'appIco': appModule.appIco } self.appDetailList.append(d) diff --git a/vnpy/trader/vtFunction.py b/vnpy/trader/vtFunction.py index 4cb258bd..3a1d76d6 100644 --- a/vnpy/trader/vtFunction.py +++ b/vnpy/trader/vtFunction.py @@ -9,9 +9,11 @@ import decimal import json from datetime import datetime + MAX_NUMBER = 10000000000000 MAX_DECIMAL = 4 + #---------------------------------------------------------------------- def safeUnicode(value): """检查接口数据潜在的错误,保证转化为的字符串正确""" @@ -28,28 +30,27 @@ def safeUnicode(value): return unicode(value) + #---------------------------------------------------------------------- def todayDate(): """获取当前本机电脑时间的日期""" return datetime.now().replace(hour=0, minute=0, second=0, microsecond=0) + +# 图标路径 +iconPathDict = {} + +path = os.path.abspath(os.path.dirname(__file__)) +for root, subdirs, files in os.walk(path): + for fileName in files: + if '.ico' in fileName: + iconPathDict[fileName] = os.path.join(root, fileName) + #---------------------------------------------------------------------- -def loadIconPath(): - """加载程序图标路径""" - iconName = 'vnpy.ico' - - # 首先尝试从当前目录加载图标 - path = os.getcwd() - iconPath = os.path.join(path, iconName) - if os.path.isfile(iconPath): - return iconPath - - # 如果失败则从vt根目录加载图标 - else: - path = os.path.abspath(os.path.dirname(__file__)) - iconPath = os.path.join(path, iconName) - return iconPath - +def loadIconPath(iconName): + """加载程序图标路径""" + global iconPathDict + return iconPathDict.get(iconName, '')