修复直达接口的安全退出问题
This commit is contained in:
parent
aa13b14385
commit
763ce46410
@ -77,7 +77,11 @@ class ShzdGateway(VtGateway):
|
|||||||
"""连接"""
|
"""连接"""
|
||||||
# 载入json文件
|
# 载入json文件
|
||||||
fileName = self.gatewayName + '_connect.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)
|
fileName = os.path.join(path, fileName)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -146,7 +150,7 @@ class ShzdGateway(VtGateway):
|
|||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def close(self):
|
def close(self):
|
||||||
"""关闭"""
|
"""关闭"""
|
||||||
self.api.release() # 释放接口对象
|
self.api.close() # 释放接口对象
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def initQuery(self):
|
def initQuery(self):
|
||||||
@ -223,6 +227,9 @@ class ShzdGatewayApi(ShzdApi):
|
|||||||
# 持仓缓存
|
# 持仓缓存
|
||||||
self.posDict = {} # key为vtPositionName,value为VtPositionData
|
self.posDict = {} # key为vtPositionName,value为VtPositionData
|
||||||
|
|
||||||
|
# 是否进行了初始化
|
||||||
|
self.inited = False
|
||||||
|
|
||||||
self.initCallbacks()
|
self.initCallbacks()
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
@ -578,6 +585,7 @@ class ShzdGatewayApi(ShzdApi):
|
|||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
self.gateway.writeLog(u'接口初始化成功')
|
self.gateway.writeLog(u'接口初始化成功')
|
||||||
|
self.inited = True
|
||||||
|
|
||||||
# 连接交易服务器
|
# 连接交易服务器
|
||||||
n = self.registerFront(frontAddress, frontPort)
|
n = self.registerFront(frontAddress, frontPort)
|
||||||
@ -710,6 +718,11 @@ class ShzdGatewayApi(ShzdApi):
|
|||||||
req['11'] = self.accountNo
|
req['11'] = self.accountNo
|
||||||
self.shzdSendInfoToTrade(req)
|
self.shzdSendInfoToTrade(req)
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
def close(self):
|
||||||
|
"""关闭接口"""
|
||||||
|
if self.inited:
|
||||||
|
self.release()
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def printDict(d):
|
def printDict(d):
|
||||||
|
Loading…
Reference in New Issue
Block a user