From c77d133d513769398748e66733263af5ff6520e4 Mon Sep 17 00:00:00 2001 From: studynon Date: Tue, 28 Aug 2018 23:15:32 +0800 Subject: [PATCH] =?UTF-8?q?[Mod]gateway=E7=9B=B8=E5=85=B3=E7=9A=84python3?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=E6=80=A7=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- beta/gateway/coincheckGateway/coincheckGateway.py | 3 ++- beta/gateway/korbitGateway/korbitGateway.py | 5 +++-- beta/gateway/zbGateway/zbGateway.py | 5 +++-- beta/quantos/tkproGateway/tkproGateway.py | 3 ++- vnpy/trader/gateway/bigoneGateway/bigoneGateway.py | 5 +++-- vnpy/trader/gateway/binanceGateway/binanceGateway.py | 5 +++-- vnpy/trader/gateway/bitfinexGateway/bitfinexGateway.py | 3 ++- vnpy/trader/gateway/bithumb/bithumbGateway.py | 3 ++- vnpy/trader/gateway/bitmexGateway/bitmexGateway.py | 5 +++-- vnpy/trader/gateway/ccxtGateway/ccxtGateway.py | 5 +++-- vnpy/trader/gateway/coinbaseGateway/coinbaseGateway.py | 5 +++-- vnpy/trader/gateway/cshshlpGateway/cshshlpGateway.py | 3 ++- vnpy/trader/gateway/fcoinGateway/fcoinGateway.py | 5 +++-- vnpy/trader/gateway/femasGateway/femasGateway.py | 5 +++-- vnpy/trader/gateway/fxcmGateway/fxcmGateway.py | 5 +++-- vnpy/trader/gateway/ibGateway/ibGateway.py | 5 +++-- vnpy/trader/gateway/ksgoldGateway/ksgoldGateway.py | 3 ++- vnpy/trader/gateway/ksotpGateway/ksotpGateway.py | 3 ++- vnpy/trader/gateway/lbankGateway/lbankGateway.py | 3 ++- vnpy/trader/gateway/ltsGateway/ltsGateway.py | 5 +++-- vnpy/trader/gateway/okexGateway/okexGateway.py | 5 +++-- vnpy/trader/gateway/qdpGateway/qdpGateway.py | 3 ++- vnpy/trader/gateway/secGateway/secGateway.py | 5 +++-- vnpy/trader/gateway/sgitGateway/sgitGateway.py | 5 +++-- vnpy/trader/gateway/shzdGateway/shzdGateway.py | 5 +++-- vnpy/trader/gateway/xspeedGateway/xspeedGateway.py | 5 +++-- vnpy/trader/gateway/xtpGateway/xtpGateway.py | 7 ++++--- 27 files changed, 73 insertions(+), 46 deletions(-) diff --git a/beta/gateway/coincheckGateway/coincheckGateway.py b/beta/gateway/coincheckGateway/coincheckGateway.py index 96ce0b67..b3d5b292 100644 --- a/beta/gateway/coincheckGateway/coincheckGateway.py +++ b/beta/gateway/coincheckGateway/coincheckGateway.py @@ -46,7 +46,7 @@ class CoincheckGateway(VtGateway): """连接""" # 载入json文件 try: - f = file(self.filePath) + f = open(self.filePath) except IOError: log = VtLogData() log.gatewayName = self.gatewayName @@ -56,6 +56,7 @@ class CoincheckGateway(VtGateway): # 解析json文件 setting = json.load(f) + f.close() try: accessKey = str(setting['accessKey']) secretKey = str(setting['secretKey']) diff --git a/beta/gateway/korbitGateway/korbitGateway.py b/beta/gateway/korbitGateway/korbitGateway.py index 07928757..83b69044 100644 --- a/beta/gateway/korbitGateway/korbitGateway.py +++ b/beta/gateway/korbitGateway/korbitGateway.py @@ -47,7 +47,7 @@ class korbitGateway(VtGateway): """连接""" # 载入json文件 try: - f = file(self.filePath) + f = open(self.filePath) except IOError: log = VtLogData() log.gatewayName = self.gatewayName @@ -57,6 +57,7 @@ class korbitGateway(VtGateway): # 解析json文件 setting = json.load(f) + f.close() try: self.accountID = str(setting["accountID"]) self.accessKey = str(setting['accessKey']) @@ -584,4 +585,4 @@ class KorbitDataApi(vnkorbit.Korbit_DataApi): dt = datetime.fromtimestamp(float(s)/1e3) time = dt.strftime("%H:%M:%S.%f") date = dt.strftime("%Y%m%d") - return dt , date, time \ No newline at end of file + return dt , date, time diff --git a/beta/gateway/zbGateway/zbGateway.py b/beta/gateway/zbGateway/zbGateway.py index 839cea06..e538da98 100644 --- a/beta/gateway/zbGateway/zbGateway.py +++ b/beta/gateway/zbGateway/zbGateway.py @@ -65,7 +65,7 @@ class zbGateway(VtGateway): """连接""" # 载入json文件 try: - f = file(self.filePath) + f = open(self.filePath) except IOError: log = VtLogData() log.gatewayName = self.gatewayName @@ -75,6 +75,7 @@ class zbGateway(VtGateway): # 解析json文件 setting = json.load(f) + f.close() try: apiKey = str(setting['apiKey']) secretKey = str(setting['secretKey']) @@ -855,4 +856,4 @@ class ZB_API_Spot(ZB_Sub_Spot_Api): time = dt.strftime("%H:%M:%S.%f") date = dt.strftime("%Y%m%d") return date, time - \ No newline at end of file + diff --git a/beta/quantos/tkproGateway/tkproGateway.py b/beta/quantos/tkproGateway/tkproGateway.py index ddd53e4a..39dbe4d9 100644 --- a/beta/quantos/tkproGateway/tkproGateway.py +++ b/beta/quantos/tkproGateway/tkproGateway.py @@ -96,7 +96,7 @@ class TkproGateway(VtGateway): def connect(self): """连接""" try: - f = file(self.filePath) + f = open(self.filePath) except IOError: log = VtLogData() log.gatewayName = self.gatewayName @@ -105,6 +105,7 @@ class TkproGateway(VtGateway): return setting = json.load(f) + f.close() try: username = str(setting['username']) token = str(setting['token']) diff --git a/vnpy/trader/gateway/bigoneGateway/bigoneGateway.py b/vnpy/trader/gateway/bigoneGateway/bigoneGateway.py index 1c60ecaa..adb83e8d 100644 --- a/vnpy/trader/gateway/bigoneGateway/bigoneGateway.py +++ b/vnpy/trader/gateway/bigoneGateway/bigoneGateway.py @@ -52,7 +52,7 @@ class BigoneGateway(VtGateway): def connect(self): """连接""" try: - f = file(self.filePath) + f = open(self.filePath) except IOError: log = VtLogData() log.gatewayName = self.gatewayName @@ -62,6 +62,7 @@ class BigoneGateway(VtGateway): # 解析json文件 setting = json.load(f) + f.close() try: apiKey = str(setting['apiKey']) apiSecret = str(setting['apiSecret']) @@ -509,4 +510,4 @@ def printDict(d): l.sort() for k in l: print(k, d[k]) - \ No newline at end of file + diff --git a/vnpy/trader/gateway/binanceGateway/binanceGateway.py b/vnpy/trader/gateway/binanceGateway/binanceGateway.py index d133021f..f50598af 100644 --- a/vnpy/trader/gateway/binanceGateway/binanceGateway.py +++ b/vnpy/trader/gateway/binanceGateway/binanceGateway.py @@ -68,7 +68,7 @@ class BinanceGateway(VtGateway): def connect(self): """连接""" try: - f = file(self.filePath) + f = open(self.filePath) except IOError: log = VtLogData() log.gatewayName = self.gatewayName @@ -78,6 +78,7 @@ class BinanceGateway(VtGateway): # 解析json文件 setting = json.load(f) + f.close() try: apiKey = str(setting['apiKey']) secretKey = str(setting['secretKey']) @@ -487,4 +488,4 @@ class GatewayApi(BinanceApi): #---------------------------------------------------------------------- def cancel(self, cancelOrderReq): """""" - self.cancelOrder(cancelOrderReq.symbol, origClientOrderId=cancelOrderReq.orderID) \ No newline at end of file + self.cancelOrder(cancelOrderReq.symbol, origClientOrderId=cancelOrderReq.orderID) diff --git a/vnpy/trader/gateway/bitfinexGateway/bitfinexGateway.py b/vnpy/trader/gateway/bitfinexGateway/bitfinexGateway.py index 46947cd9..86cc5368 100644 --- a/vnpy/trader/gateway/bitfinexGateway/bitfinexGateway.py +++ b/vnpy/trader/gateway/bitfinexGateway/bitfinexGateway.py @@ -51,7 +51,7 @@ class BitfinexGateay(VtGateway): def connect(self): """连接""" try: - f = file(self.filePath) + f = open(self.filePath) except IOError: log = VtLogData() log.gatewayName = self.gatewayName @@ -61,6 +61,7 @@ class BitfinexGateay(VtGateway): # 解析json文件 setting = json.load(f) + f.close() try: apiKey = str(setting['apiKey']) secretKey = str(setting['secretKey']) diff --git a/vnpy/trader/gateway/bithumb/bithumbGateway.py b/vnpy/trader/gateway/bithumb/bithumbGateway.py index 091198fd..42c3e8e5 100644 --- a/vnpy/trader/gateway/bithumb/bithumbGateway.py +++ b/vnpy/trader/gateway/bithumb/bithumbGateway.py @@ -78,7 +78,7 @@ class BithumbGateway(VtGateway): def connect(self): """连接""" try: - f = file(self.filePath) + f = open(self.filePath) except IOError: log = VtLogData() log.gatewayName = self.gatewayName @@ -88,6 +88,7 @@ class BithumbGateway(VtGateway): # 解析json文件 setting = json.load(f) + f.close() try: apiKey = str(setting['apiKey']) apiSecret = str(setting['apiSecret']) diff --git a/vnpy/trader/gateway/bitmexGateway/bitmexGateway.py b/vnpy/trader/gateway/bitmexGateway/bitmexGateway.py index 599ead71..5341d86f 100644 --- a/vnpy/trader/gateway/bitmexGateway/bitmexGateway.py +++ b/vnpy/trader/gateway/bitmexGateway/bitmexGateway.py @@ -61,7 +61,7 @@ class BitmexGateway(VtGateway): def connect(self): """连接""" try: - f = file(self.filePath) + f = open(self.filePath) except IOError: log = VtLogData() log.gatewayName = self.gatewayName @@ -71,6 +71,7 @@ class BitmexGateway(VtGateway): # 解析json文件 setting = json.load(f) + f.close() try: apiKey = str(setting['apiKey']) apiSecret = str(setting['apiSecret']) @@ -531,4 +532,4 @@ def printDict(d): l.sort() for k in l: print(k, d[k]) - \ No newline at end of file + diff --git a/vnpy/trader/gateway/ccxtGateway/ccxtGateway.py b/vnpy/trader/gateway/ccxtGateway/ccxtGateway.py index 5461e304..e776fc4a 100644 --- a/vnpy/trader/gateway/ccxtGateway/ccxtGateway.py +++ b/vnpy/trader/gateway/ccxtGateway/ccxtGateway.py @@ -59,7 +59,7 @@ class CcxtGateway(VtGateway): def connect(self): """连接""" try: - f = file(self.filePath) + f = open(self.filePath) except IOError: log = VtLogData() log.gatewayName = self.gatewayName @@ -69,6 +69,7 @@ class CcxtGateway(VtGateway): # 解析json文件 setting = json.load(f) + f.close() try: exchange = str(setting['exchange']) apiKey = str(setting['apiKey']) @@ -544,4 +545,4 @@ class CcxtApi(object): """""" self.qryDepth() self.qryTicker() - \ No newline at end of file + diff --git a/vnpy/trader/gateway/coinbaseGateway/coinbaseGateway.py b/vnpy/trader/gateway/coinbaseGateway/coinbaseGateway.py index f46ecaf9..05d5934f 100644 --- a/vnpy/trader/gateway/coinbaseGateway/coinbaseGateway.py +++ b/vnpy/trader/gateway/coinbaseGateway/coinbaseGateway.py @@ -58,7 +58,7 @@ class CoinbaseGateway(VtGateway): def connect(self): """连接""" try: - f = file(self.filePath) + f = open(self.filePath) except IOError: log = VtLogData() log.gatewayName = self.gatewayName @@ -68,6 +68,7 @@ class CoinbaseGateway(VtGateway): # 解析json文件 setting = json.load(f) + f.close() try: apiKey = str(setting['apiKey']) secretKey = str(setting['secretKey']) @@ -661,4 +662,4 @@ def printDict(d): l.sort() for k in l: print(k, d[k]) - \ No newline at end of file + diff --git a/vnpy/trader/gateway/cshshlpGateway/cshshlpGateway.py b/vnpy/trader/gateway/cshshlpGateway/cshshlpGateway.py index 4c1424a7..e318a70f 100644 --- a/vnpy/trader/gateway/cshshlpGateway/cshshlpGateway.py +++ b/vnpy/trader/gateway/cshshlpGateway/cshshlpGateway.py @@ -104,7 +104,7 @@ class CshshlpGateway(VtGateway): """连接""" # 载入json文件 try: - f = file(self.filePath) + f = open(self.filePath) except IOError: log = VtLogData() log.gatewayName = self.gatewayName @@ -114,6 +114,7 @@ class CshshlpGateway(VtGateway): # 解析json文件 setting = json.load(f) + f.close() try: userID = str(setting['userID']) diff --git a/vnpy/trader/gateway/fcoinGateway/fcoinGateway.py b/vnpy/trader/gateway/fcoinGateway/fcoinGateway.py index 8c9a054d..15d0208c 100644 --- a/vnpy/trader/gateway/fcoinGateway/fcoinGateway.py +++ b/vnpy/trader/gateway/fcoinGateway/fcoinGateway.py @@ -60,7 +60,7 @@ class FcoinGateway(VtGateway): def connect(self): """连接""" try: - f = file(self.filePath) + f = open(self.filePath) except IOError: log = VtLogData() log.gatewayName = self.gatewayName @@ -70,6 +70,7 @@ class FcoinGateway(VtGateway): # 解析json文件 setting = json.load(f) + f.close() try: apiKey = str(setting['apiKey']) apiSecret = str(setting['apiSecret']) @@ -579,4 +580,4 @@ def printDict(d): l.sort() for k in l: print(k, d[k]) - \ No newline at end of file + diff --git a/vnpy/trader/gateway/femasGateway/femasGateway.py b/vnpy/trader/gateway/femasGateway/femasGateway.py index 88ba3d42..d327724f 100644 --- a/vnpy/trader/gateway/femasGateway/femasGateway.py +++ b/vnpy/trader/gateway/femasGateway/femasGateway.py @@ -81,7 +81,7 @@ class FemasGateway(VtGateway): """连接""" # 载入json文件 try: - f = file(self.filePath) + f = open(self.filePath) except IOError: log = VtLogData() log.gatewayName = self.gatewayName @@ -91,6 +91,7 @@ class FemasGateway(VtGateway): # 解析json文件 setting = json.load(f) + f.close() try: userID = str(setting['userID']) password = str(setting['password']) @@ -944,4 +945,4 @@ class FemasTdApi(TdApi): #---------------------------------------------------------------------- def onRspQryInvestorMargin(self, data, error, n, last): """""" - pass \ No newline at end of file + pass diff --git a/vnpy/trader/gateway/fxcmGateway/fxcmGateway.py b/vnpy/trader/gateway/fxcmGateway/fxcmGateway.py index f0345dd6..da3918f7 100644 --- a/vnpy/trader/gateway/fxcmGateway/fxcmGateway.py +++ b/vnpy/trader/gateway/fxcmGateway/fxcmGateway.py @@ -61,7 +61,7 @@ class FxcmGateway(VtGateway): """连接""" # 载入json文件 try: - f = file(self.filePath) + f = open(self.filePath) except IOError: log = VtLogData() log.gatewayName = self.gatewayName @@ -71,6 +71,7 @@ class FxcmGateway(VtGateway): # 解析json文件 setting = json.load(f) + f.close() try: port = int(setting['port']) url = str(setting['url']) @@ -564,4 +565,4 @@ def getTime(s): t = ':'.join([hour, minute, second]) d = ''.join([year, month, day]) - return d, t \ No newline at end of file + return d, t diff --git a/vnpy/trader/gateway/ibGateway/ibGateway.py b/vnpy/trader/gateway/ibGateway/ibGateway.py index 3f70826b..ee1e99dd 100644 --- a/vnpy/trader/gateway/ibGateway/ibGateway.py +++ b/vnpy/trader/gateway/ibGateway/ibGateway.py @@ -149,7 +149,7 @@ class IbGateway(VtGateway): """连接""" # 载入json文件 try: - f = file(self.filePath) + f = open(self.filePath) except IOError: log = VtLogData() log.gatewayName = self.gatewayName @@ -159,6 +159,7 @@ class IbGateway(VtGateway): # 解析json文件 setting = json.load(f) + f.close() try: self.host = str(setting['host']) self.port = int(setting['port']) @@ -737,4 +738,4 @@ class IbWrapper(IbApi): def softDollarTiers(self, reqId, tiers): """""" pass - \ No newline at end of file + diff --git a/vnpy/trader/gateway/ksgoldGateway/ksgoldGateway.py b/vnpy/trader/gateway/ksgoldGateway/ksgoldGateway.py index d7ebb69e..2ff45385 100644 --- a/vnpy/trader/gateway/ksgoldGateway/ksgoldGateway.py +++ b/vnpy/trader/gateway/ksgoldGateway/ksgoldGateway.py @@ -54,7 +54,7 @@ class KsgoldGateway(VtGateway): """连接""" # 载入json文件 try: - f = file(self.filePath) + f = open(self.filePath) except IOError: log = VtLogData() log.gatewayName = self.gatewayName @@ -64,6 +64,7 @@ class KsgoldGateway(VtGateway): # 解析json文件 setting = json.load(f) + f.close() try: accountID = str(setting['accountID']) password = str(setting['password']) diff --git a/vnpy/trader/gateway/ksotpGateway/ksotpGateway.py b/vnpy/trader/gateway/ksotpGateway/ksotpGateway.py index c5b0a465..e0020f00 100644 --- a/vnpy/trader/gateway/ksotpGateway/ksotpGateway.py +++ b/vnpy/trader/gateway/ksotpGateway/ksotpGateway.py @@ -76,7 +76,7 @@ class KsotpGateway(VtGateway): """连接""" # 载入json文件 try: - f = file(self.filePath) + f = open(self.filePath) except IOError: log = VtLogData() log.gatewayName = self.gatewayName @@ -86,6 +86,7 @@ class KsotpGateway(VtGateway): # 解析json文件 setting = json.load(f) + f.close() try: userID = str(setting['userID']) password = str(setting['password']) diff --git a/vnpy/trader/gateway/lbankGateway/lbankGateway.py b/vnpy/trader/gateway/lbankGateway/lbankGateway.py index 744eec64..b9b83e84 100644 --- a/vnpy/trader/gateway/lbankGateway/lbankGateway.py +++ b/vnpy/trader/gateway/lbankGateway/lbankGateway.py @@ -50,7 +50,7 @@ class LbankGateway(VtGateway): def connect(self): """连接""" try: - f = file(self.filePath) + f = open(self.filePath) except IOError: log = VtLogData() log.gatewayName = self.gatewayName @@ -60,6 +60,7 @@ class LbankGateway(VtGateway): # 解析json文件 setting = json.load(f) + f.close() try: apiKey = str(setting['apiKey']) secretKey = str(setting['secretKey']) diff --git a/vnpy/trader/gateway/ltsGateway/ltsGateway.py b/vnpy/trader/gateway/ltsGateway/ltsGateway.py index 00942059..582c0c4d 100644 --- a/vnpy/trader/gateway/ltsGateway/ltsGateway.py +++ b/vnpy/trader/gateway/ltsGateway/ltsGateway.py @@ -78,7 +78,7 @@ class LtsGateway(VtGateway): """连接""" # 载入json 文件 try: - f = file(self.filePath) + f = open(self.filePath) except IOError: log = VtLogData() log.gatewayName = self.gatewayName @@ -88,6 +88,7 @@ class LtsGateway(VtGateway): # 解析json文件 setting = json.load(f) + f.close() try: userID = str(setting['userID']) mdPassword = str(setting['mdPassword']) @@ -1239,4 +1240,4 @@ class LtsQryApi(QryApi): self.exit() - \ No newline at end of file + diff --git a/vnpy/trader/gateway/okexGateway/okexGateway.py b/vnpy/trader/gateway/okexGateway/okexGateway.py index be924f81..fddb58e2 100644 --- a/vnpy/trader/gateway/okexGateway/okexGateway.py +++ b/vnpy/trader/gateway/okexGateway/okexGateway.py @@ -63,7 +63,7 @@ class OkexGateway(VtGateway): """连接""" # 载入json文件 try: - f = file(self.filePath) + f = open(self.filePath) except IOError: log = VtLogData() log.gatewayName = self.gatewayName @@ -73,6 +73,7 @@ class OkexGateway(VtGateway): # 解析json文件 setting = json.load(f) + f.close() try: apiKey = str(setting['apiKey']) secretKey = str(setting['secretKey']) @@ -628,4 +629,4 @@ class SpotApi(OkexSpotApi): self.subscribeSpotDepth(symbol, 5) self.subSpotOrder(symbol) self.subSpotBalance(symbol) - \ No newline at end of file + diff --git a/vnpy/trader/gateway/qdpGateway/qdpGateway.py b/vnpy/trader/gateway/qdpGateway/qdpGateway.py index 1c621518..d693bf44 100644 --- a/vnpy/trader/gateway/qdpGateway/qdpGateway.py +++ b/vnpy/trader/gateway/qdpGateway/qdpGateway.py @@ -85,7 +85,7 @@ class QdpGateway(VtGateway): def connect(self): """连接""" try: - f = file(self.filePath) + f = open(self.filePath) except IOError: log = VtLogData() log.gatewayName = self.gatewayName @@ -95,6 +95,7 @@ class QdpGateway(VtGateway): # 解析json文件 setting = json.load(f) + f.close() try: userID = str(setting['userID']) password = str(setting['password']) diff --git a/vnpy/trader/gateway/secGateway/secGateway.py b/vnpy/trader/gateway/secGateway/secGateway.py index a5ff3d01..b1c51d6b 100644 --- a/vnpy/trader/gateway/secGateway/secGateway.py +++ b/vnpy/trader/gateway/secGateway/secGateway.py @@ -82,7 +82,7 @@ class SecGateway(VtGateway): def connect(self): """连接""" try: - f = file(self.filePath) + f = open(self.filePath) except IOError: log = VtLogData() log.gatewayName = self.gatewayName @@ -92,6 +92,7 @@ class SecGateway(VtGateway): # 解析json文件 setting = json.load(f) + f.close() try: accountID = str(setting['accountID']) password = str(setting['password']) @@ -1587,4 +1588,4 @@ def checkOptionSymbol(symbol): if len(symbol) > 6: return True return False - \ No newline at end of file + diff --git a/vnpy/trader/gateway/sgitGateway/sgitGateway.py b/vnpy/trader/gateway/sgitGateway/sgitGateway.py index d46501a3..c1026718 100644 --- a/vnpy/trader/gateway/sgitGateway/sgitGateway.py +++ b/vnpy/trader/gateway/sgitGateway/sgitGateway.py @@ -96,7 +96,7 @@ class SgitGateway(VtGateway): def connect(self): """连接""" try: - f = file(self.filePath) + f = open(self.filePath) except IOError: log = VtLogData() log.gatewayName = self.gatewayName @@ -106,6 +106,7 @@ class SgitGateway(VtGateway): # 解析json文件 setting = json.load(f) + f.close() try: userID = str(setting['userID']) password = str(setting['password']) @@ -1405,4 +1406,4 @@ class PositionBuffer(object): #---------------------------------------------------------------------- def getPos(self): """获取当前的持仓数据""" - return copy(self.pos) \ No newline at end of file + return copy(self.pos) diff --git a/vnpy/trader/gateway/shzdGateway/shzdGateway.py b/vnpy/trader/gateway/shzdGateway/shzdGateway.py index d49ba6b0..1b7a09f1 100644 --- a/vnpy/trader/gateway/shzdGateway/shzdGateway.py +++ b/vnpy/trader/gateway/shzdGateway/shzdGateway.py @@ -77,7 +77,7 @@ class ShzdGateway(VtGateway): def connect(self): """连接""" try: - f = file(self.filePath) + f = open(self.filePath) except IOError: log = VtLogData() log.gatewayName = self.gatewayName @@ -87,6 +87,7 @@ class ShzdGateway(VtGateway): # 解析json文件 setting = json.load(f) + f.close() try: frontAddress = str(setting['frontAddress']) frontPort = int(setting['frontPort']) @@ -727,4 +728,4 @@ def printDict(d): l.sort() for k in l: print(k, ':', d[k]) - \ No newline at end of file + diff --git a/vnpy/trader/gateway/xspeedGateway/xspeedGateway.py b/vnpy/trader/gateway/xspeedGateway/xspeedGateway.py index 0d5c883c..1f9b7ef5 100644 --- a/vnpy/trader/gateway/xspeedGateway/xspeedGateway.py +++ b/vnpy/trader/gateway/xspeedGateway/xspeedGateway.py @@ -86,7 +86,7 @@ class XspeedGateway(VtGateway): def connect(self): """连接""" try: - f = file(self.filePath) + f = open(self.filePath) except IOError: log = VtLogData() log.gatewayName = self.gatewayName @@ -96,6 +96,7 @@ class XspeedGateway(VtGateway): # 解析json文件 setting = json.load(f) + f.close() try: accountID = str(setting['accountID']) password = str(setting['password']) @@ -1220,4 +1221,4 @@ class XspeedTdApi(TdApi): def onRspEquityComputMode(self, data) : """""" pass - \ No newline at end of file + diff --git a/vnpy/trader/gateway/xtpGateway/xtpGateway.py b/vnpy/trader/gateway/xtpGateway/xtpGateway.py index 95a30581..4f286610 100644 --- a/vnpy/trader/gateway/xtpGateway/xtpGateway.py +++ b/vnpy/trader/gateway/xtpGateway/xtpGateway.py @@ -111,7 +111,7 @@ class XtpGateway(VtGateway): def connect(self): """连接""" try: - f = file(self.filePath) + f = open(self.filePath) except IOError: log = VtLogData() log.gatewayName = self.gatewayName @@ -120,7 +120,8 @@ class XtpGateway(VtGateway): return # 解析json文件 - setting = json.load(f) + setting = json.load(f) + f.close() try: userID = str(setting['userID']) password = str(setting['password']) @@ -823,4 +824,4 @@ class XtpTdApi(TraderApi): log = VtLogData() log.gatewayName = self.gatewayName log.logContent = content - self.gateway.onLog(log) \ No newline at end of file + self.gateway.onLog(log)