From 8e5ae0565c2c94cca67928b8a7d312c1a9291fe0 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Thu, 1 Jun 2017 16:40:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=8E=A5=E5=8F=A3=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/trader/__init__.py | 2 +- vnpy/trader/app/ctaStrategy/ctaEngine.py | 5 ++++ vnpy/trader/app/riskManager/rmEngine.py | 6 +++++ .../gateway/ctpGateway/CTP_connect.json | 4 ++-- vnpy/trader/gateway/ksgoldGateway/__init__.py | 3 ++- vnpy/trader/gateway/ksotpGateway/__init__.py | 3 ++- vnpy/trader/gateway/lhangGateway/__init__.py | 3 ++- vnpy/trader/gateway/ltsGateway/__init__.py | 3 ++- vnpy/trader/gateway/oandaGateway/__init__.py | 3 ++- vnpy/trader/gateway/okcoinGateway/__init__.py | 3 ++- vnpy/trader/gateway/qdpGateway/__init__.py | 3 ++- vnpy/trader/gateway/sgitGateway/__init__.py | 3 ++- vnpy/trader/gateway/shzdGateway/__init__.py | 3 ++- vnpy/trader/gateway/windGateway/__init__.py | 3 ++- .../trader/gateway/windGateway/windGateway.py | 3 ++- vnpy/trader/gateway/xspeedGateway/__init__.py | 3 ++- vnpy/trader/vtEngine.py | 7 +++--- vnpy/trader/vtMain.py | 23 ++++++++++++++++--- 18 files changed, 62 insertions(+), 21 deletions(-) diff --git a/vnpy/trader/__init__.py b/vnpy/trader/__init__.py index dd55d697..6eb3265e 100644 --- a/vnpy/trader/__init__.py +++ b/vnpy/trader/__init__.py @@ -1 +1 @@ -# encoding: UTF-8 +# encoding: UTF-8 \ No newline at end of file diff --git a/vnpy/trader/app/ctaStrategy/ctaEngine.py b/vnpy/trader/app/ctaStrategy/ctaEngine.py index 2f5d17ee..9a24a61b 100644 --- a/vnpy/trader/app/ctaStrategy/ctaEngine.py +++ b/vnpy/trader/app/ctaStrategy/ctaEngine.py @@ -579,6 +579,11 @@ class CtaEngine(object): newPrice = round(price/priceTick, 0) * priceTick return newPrice + + #---------------------------------------------------------------------- + def stop(self): + """停止""" + pass ######################################################################## diff --git a/vnpy/trader/app/riskManager/rmEngine.py b/vnpy/trader/app/riskManager/rmEngine.py index cc8e5c25..54ef606e 100644 --- a/vnpy/trader/app/riskManager/rmEngine.py +++ b/vnpy/trader/app/riskManager/rmEngine.py @@ -252,3 +252,9 @@ class RmEngine(object): self.writeRiskLog(u'风险管理功能启动') else: self.writeRiskLog(u'风险管理功能停止') + + #---------------------------------------------------------------------- + def stop(self): + """停止""" + self.saveSetting() + diff --git a/vnpy/trader/gateway/ctpGateway/CTP_connect.json b/vnpy/trader/gateway/ctpGateway/CTP_connect.json index e4bfa6b8..1b4d5a42 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": "simnow申请", - "password": "simnow申请" + "userID": "000300", + "password": "19890624" } \ No newline at end of file diff --git a/vnpy/trader/gateway/ksgoldGateway/__init__.py b/vnpy/trader/gateway/ksgoldGateway/__init__.py index 3d2cfeca..b81b6ef3 100644 --- a/vnpy/trader/gateway/ksgoldGateway/__init__.py +++ b/vnpy/trader/gateway/ksgoldGateway/__init__.py @@ -1,8 +1,9 @@ # encoding: UTF-8 from vnpy.trader import vtConstant -from ksgoldGateway import KsgoldGateway as gateway +from ksgoldGateway import KsgoldGateway +gatewayClass = KsgoldGateway gatewayName = 'KSGOLD' gatewayDisplayName = u'金仕达黄金' gatewayType = vtConstant.GATEWAYTYPE_FUTURES diff --git a/vnpy/trader/gateway/ksotpGateway/__init__.py b/vnpy/trader/gateway/ksotpGateway/__init__.py index 1997ecdb..cf9c5dbb 100644 --- a/vnpy/trader/gateway/ksotpGateway/__init__.py +++ b/vnpy/trader/gateway/ksotpGateway/__init__.py @@ -1,8 +1,9 @@ # encoding: UTF-8 from vnpy.trader import vtConstant -from ksotpGateway import KsotpGateway as gateway +from ksotpGateway import KsotpGateway +gatewayClass = KsotpGateway gatewayName = 'KSOTP' gatewayDisplayName = u'金仕达期权' gatewayType = vtConstant.GATEWAYTYPE_EQUITY diff --git a/vnpy/trader/gateway/lhangGateway/__init__.py b/vnpy/trader/gateway/lhangGateway/__init__.py index f7e46d31..d07d4db8 100644 --- a/vnpy/trader/gateway/lhangGateway/__init__.py +++ b/vnpy/trader/gateway/lhangGateway/__init__.py @@ -1,8 +1,9 @@ # encoding: UTF-8 from vnpy.trader import vtConstant -from lhangGateway import LhangGateway as gateway +from lhangGateway import LhangGateway +gatewayClass = LhangGateway gatewayName = 'LHANG' gatewayDisplayName = u'链行' gatewayType = vtConstant.GATEWAYTYPE_BTC diff --git a/vnpy/trader/gateway/ltsGateway/__init__.py b/vnpy/trader/gateway/ltsGateway/__init__.py index 78a0ad1f..cbb88696 100644 --- a/vnpy/trader/gateway/ltsGateway/__init__.py +++ b/vnpy/trader/gateway/ltsGateway/__init__.py @@ -1,8 +1,9 @@ # encoding: UTF-8 from vnpy.trader import vtConstant -from ltsGateway import LtsGateway as gateway +from ltsGateway import LtsGateway +gatewayClass = LtsGateway gatewayName = 'LTS' gatewayDisplayName = gatewayName gatewayType = vtConstant.GATEWAYTYPE_EQUITY diff --git a/vnpy/trader/gateway/oandaGateway/__init__.py b/vnpy/trader/gateway/oandaGateway/__init__.py index f1b72302..0ce2fb0d 100644 --- a/vnpy/trader/gateway/oandaGateway/__init__.py +++ b/vnpy/trader/gateway/oandaGateway/__init__.py @@ -1,8 +1,9 @@ # encoding: UTF-8 from vnpy.trader import vtConstant -from oandaGateway import OandaGateway as gateway +from oandaGateway import OandaGateway +gatewayClass = OandaGateway gatewayName = 'OANDA' gatewayDisplayName = gatewayName gatewayType = vtConstant.GATEWAYTYPE_INTERNATIONAL diff --git a/vnpy/trader/gateway/okcoinGateway/__init__.py b/vnpy/trader/gateway/okcoinGateway/__init__.py index b3cc11ce..b41a3ecf 100644 --- a/vnpy/trader/gateway/okcoinGateway/__init__.py +++ b/vnpy/trader/gateway/okcoinGateway/__init__.py @@ -1,8 +1,9 @@ # encoding: UTF-8 from vnpy.trader import vtConstant -from okcoinGateway import OkcoinGateway as gateway +from okcoinGateway import OkcoinGateway +gatewayClass = OkcoinGateway gatewayName = 'OKCOIN' gatewayDisplayName = u'币行' gatewayType = vtConstant.GATEWAYTYPE_BTC diff --git a/vnpy/trader/gateway/qdpGateway/__init__.py b/vnpy/trader/gateway/qdpGateway/__init__.py index 39634486..4fb85e9b 100644 --- a/vnpy/trader/gateway/qdpGateway/__init__.py +++ b/vnpy/trader/gateway/qdpGateway/__init__.py @@ -1,8 +1,9 @@ # encoding: UTF-8 from vnpy.trader import vtConstant -from qdpGateway import QdpGateway as gateway +from qdpGateway import QdpGateway +gatewayClass = QdpGateway gatewayName = 'QDP' gatewayDisplayName = gatewayName gatewayType = vtConstant.GATEWAYTYPE_FUTURES diff --git a/vnpy/trader/gateway/sgitGateway/__init__.py b/vnpy/trader/gateway/sgitGateway/__init__.py index ec447058..2be6983b 100644 --- a/vnpy/trader/gateway/sgitGateway/__init__.py +++ b/vnpy/trader/gateway/sgitGateway/__init__.py @@ -1,8 +1,9 @@ # encoding: UTF-8 from vnpy.trader import vtConstant -from sgitGateway import SgitGateway as gateway +from sgitGateway import SgitGateway +gatewayClass = SgitGateway gatewayName = 'SGIT' gatewayDisplayName = u'飞鼠' gatewayType = vtConstant.GATEWAYTYPE_FUTURES diff --git a/vnpy/trader/gateway/shzdGateway/__init__.py b/vnpy/trader/gateway/shzdGateway/__init__.py index 6650ba8c..7f5d3497 100644 --- a/vnpy/trader/gateway/shzdGateway/__init__.py +++ b/vnpy/trader/gateway/shzdGateway/__init__.py @@ -1,8 +1,9 @@ # encoding: UTF-8 from vnpy.trader import vtConstant -from shzdGateway import ShzdGateway as gateway +from shzdGateway import ShzdGateway +gatewayClass = ShzdGateway gatewayName = 'SHZD' gatewayDisplayName = u'直达' gatewayType = vtConstant.GATEWAYTYPE_INTERNATIONAL diff --git a/vnpy/trader/gateway/windGateway/__init__.py b/vnpy/trader/gateway/windGateway/__init__.py index 550df75a..f2508aee 100644 --- a/vnpy/trader/gateway/windGateway/__init__.py +++ b/vnpy/trader/gateway/windGateway/__init__.py @@ -1,8 +1,9 @@ # encoding: UTF-8 from vnpy.trader import vtConstant -from windGateway import WindGateway as gateway +from windGateway import WindGateway +gatewayClass = WindGateway gatewayName = 'WIND' gatewayDisplayName = u'万得' gatewayType = vtConstant.GATEWAYTYPE_DATA diff --git a/vnpy/trader/gateway/windGateway/windGateway.py b/vnpy/trader/gateway/windGateway/windGateway.py index faae8a97..108643d1 100644 --- a/vnpy/trader/gateway/windGateway/windGateway.py +++ b/vnpy/trader/gateway/windGateway/windGateway.py @@ -133,7 +133,8 @@ class WindGateway(VtGateway): #---------------------------------------------------------------------- def close(self): - self.w.stop() + if self.w: + self.w.stop() #---------------------------------------------------------------------- def registerEvent(self): diff --git a/vnpy/trader/gateway/xspeedGateway/__init__.py b/vnpy/trader/gateway/xspeedGateway/__init__.py index 3443792a..50d26714 100644 --- a/vnpy/trader/gateway/xspeedGateway/__init__.py +++ b/vnpy/trader/gateway/xspeedGateway/__init__.py @@ -1,8 +1,9 @@ # encoding: UTF-8 from vnpy.trader import vtConstant -from xspeedGateway import XspeedGateway as gateway +from xspeedGateway import XspeedGateway +gatewayClass = XspeedGateway gatewayName = 'XSPEED' gatewayDisplayName = u'飞创' gatewayType = vtConstant.GATEWAYTYPE_FUTURES diff --git a/vnpy/trader/vtEngine.py b/vnpy/trader/vtEngine.py index 8780734c..108dd6be 100644 --- a/vnpy/trader/vtEngine.py +++ b/vnpy/trader/vtEngine.py @@ -156,10 +156,11 @@ class MainEngine(object): gateway.close() # 停止事件引擎 - self.eventEngine.stop() + self.eventEngine.stop() - # 停止数据记录引擎 - self.drEngine.stop() + # 停止上层应用引擎 + for appEngine in self.appDict.values(): + appEngine.stop() # 保存数据引擎里的合约数据到硬盘 self.dataEngine.saveContracts() diff --git a/vnpy/trader/vtMain.py b/vnpy/trader/vtMain.py index c8e82e55..f9826670 100644 --- a/vnpy/trader/vtMain.py +++ b/vnpy/trader/vtMain.py @@ -13,9 +13,13 @@ from vnpy.trader.uiQt import qApp from vnpy.trader.uiMainWindow import MainWindow # 加载底层接口 -from vnpy.trader.gateway import (ctpGateway, - ibGateway, - huobiGateway) +from vnpy.trader.gateway import (ctpGateway, femasGateway, ksotpGateway, + qdpGateway, xspeedGateway, + cshshlpGateway, ltsGateway, + ksgoldGateway, sgitGateway, + oandaGateway, ibGateway, shzdGateway, + huobiGateway, okcoinGateway, lhangGateway, + windGateway) # 加载上层应用 from vnpy.trader.app import (riskManager, dataRecorder, @@ -33,8 +37,21 @@ def main(): # 添加交易接口 me.addGateway(ctpGateway) + me.addGateway(femasGateway) + me.addGateway(ksotpGateway) + me.addGateway(qdpGateway) + me.addGateway(xspeedGateway) + me.addGateway(cshshlpGateway) + me.addGateway(ltsGateway) + me.addGateway(ksgoldGateway) + me.addGateway(sgitGateway) + me.addGateway(oandaGateway) me.addGateway(ibGateway) + me.addGateway(shzdGateway) me.addGateway(huobiGateway) + me.addGateway(okcoinGateway) + me.addGateway(lhangGateway) + me.addGateway(windGateway) # 添加上层应用 me.addApp(riskManager)