diff --git a/vn.trader/shzdGateway/shzdGateway.py b/vn.trader/shzdGateway/shzdGateway.py index eaea2303..b740406b 100644 --- a/vn.trader/shzdGateway/shzdGateway.py +++ b/vn.trader/shzdGateway/shzdGateway.py @@ -77,9 +77,13 @@ class ShzdGateway(VtGateway): """连接""" # 载入json文件 fileName = self.gatewayName + '_connect.json' - path = os.path.abspath(os.path.dirname(__file__)) + #fileName = os.getcwd() + '/shzdGateway/' + fileName + from vtFunction import filePath + path = filePath() + #path = os.path.abspath(os.path.dirname(__file__)) + print 'path:', path fileName = os.path.join(path, fileName) - + try: f = file(fileName) except IOError: @@ -146,7 +150,7 @@ class ShzdGateway(VtGateway): #---------------------------------------------------------------------- def close(self): """关闭""" - self.api.release() # 释放接口对象 + self.api.close() # 释放接口对象 #---------------------------------------------------------------------- def initQuery(self): @@ -223,6 +227,9 @@ class ShzdGatewayApi(ShzdApi): # 持仓缓存 self.posDict = {} # key为vtPositionName,value为VtPositionData + # 是否进行了初始化 + self.inited = False + self.initCallbacks() #---------------------------------------------------------------------- @@ -578,6 +585,7 @@ class ShzdGatewayApi(ShzdApi): return else: self.gateway.writeLog(u'接口初始化成功') + self.inited = True # 连接交易服务器 n = self.registerFront(frontAddress, frontPort) @@ -710,6 +718,11 @@ class ShzdGatewayApi(ShzdApi): req['11'] = self.accountNo self.shzdSendInfoToTrade(req) + #---------------------------------------------------------------------- + def close(self): + """关闭接口""" + if self.inited: + self.release() #---------------------------------------------------------------------- def printDict(d): @@ -719,4 +732,4 @@ def printDict(d): l.sort() for k in l: print k, ':', d[k] - + \ No newline at end of file