Merge pull request #1076 from studynon/dev

[Mod]gateway相关的python3兼容性修改
This commit is contained in:
vn.py 2018-08-29 12:59:34 +08:00 committed by GitHub
commit 4f2e04c776
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 73 additions and 46 deletions

View File

@ -46,7 +46,7 @@ class CoincheckGateway(VtGateway):
"""连接""" """连接"""
# 载入json文件 # 载入json文件
try: try:
f = file(self.filePath) f = open(self.filePath)
except IOError: except IOError:
log = VtLogData() log = VtLogData()
log.gatewayName = self.gatewayName log.gatewayName = self.gatewayName
@ -56,6 +56,7 @@ class CoincheckGateway(VtGateway):
# 解析json文件 # 解析json文件
setting = json.load(f) setting = json.load(f)
f.close()
try: try:
accessKey = str(setting['accessKey']) accessKey = str(setting['accessKey'])
secretKey = str(setting['secretKey']) secretKey = str(setting['secretKey'])

View File

@ -47,7 +47,7 @@ class korbitGateway(VtGateway):
"""连接""" """连接"""
# 载入json文件 # 载入json文件
try: try:
f = file(self.filePath) f = open(self.filePath)
except IOError: except IOError:
log = VtLogData() log = VtLogData()
log.gatewayName = self.gatewayName log.gatewayName = self.gatewayName
@ -57,6 +57,7 @@ class korbitGateway(VtGateway):
# 解析json文件 # 解析json文件
setting = json.load(f) setting = json.load(f)
f.close()
try: try:
self.accountID = str(setting["accountID"]) self.accountID = str(setting["accountID"])
self.accessKey = str(setting['accessKey']) self.accessKey = str(setting['accessKey'])
@ -584,4 +585,4 @@ class KorbitDataApi(vnkorbit.Korbit_DataApi):
dt = datetime.fromtimestamp(float(s)/1e3) dt = datetime.fromtimestamp(float(s)/1e3)
time = dt.strftime("%H:%M:%S.%f") time = dt.strftime("%H:%M:%S.%f")
date = dt.strftime("%Y%m%d") date = dt.strftime("%Y%m%d")
return dt , date, time return dt , date, time

View File

@ -65,7 +65,7 @@ class zbGateway(VtGateway):
"""连接""" """连接"""
# 载入json文件 # 载入json文件
try: try:
f = file(self.filePath) f = open(self.filePath)
except IOError: except IOError:
log = VtLogData() log = VtLogData()
log.gatewayName = self.gatewayName log.gatewayName = self.gatewayName
@ -75,6 +75,7 @@ class zbGateway(VtGateway):
# 解析json文件 # 解析json文件
setting = json.load(f) setting = json.load(f)
f.close()
try: try:
apiKey = str(setting['apiKey']) apiKey = str(setting['apiKey'])
secretKey = str(setting['secretKey']) secretKey = str(setting['secretKey'])
@ -855,4 +856,4 @@ class ZB_API_Spot(ZB_Sub_Spot_Api):
time = dt.strftime("%H:%M:%S.%f") time = dt.strftime("%H:%M:%S.%f")
date = dt.strftime("%Y%m%d") date = dt.strftime("%Y%m%d")
return date, time return date, time

View File

@ -96,7 +96,7 @@ class TkproGateway(VtGateway):
def connect(self): def connect(self):
"""连接""" """连接"""
try: try:
f = file(self.filePath) f = open(self.filePath)
except IOError: except IOError:
log = VtLogData() log = VtLogData()
log.gatewayName = self.gatewayName log.gatewayName = self.gatewayName
@ -105,6 +105,7 @@ class TkproGateway(VtGateway):
return return
setting = json.load(f) setting = json.load(f)
f.close()
try: try:
username = str(setting['username']) username = str(setting['username'])
token = str(setting['token']) token = str(setting['token'])

View File

@ -52,7 +52,7 @@ class BigoneGateway(VtGateway):
def connect(self): def connect(self):
"""连接""" """连接"""
try: try:
f = file(self.filePath) f = open(self.filePath)
except IOError: except IOError:
log = VtLogData() log = VtLogData()
log.gatewayName = self.gatewayName log.gatewayName = self.gatewayName
@ -62,6 +62,7 @@ class BigoneGateway(VtGateway):
# 解析json文件 # 解析json文件
setting = json.load(f) setting = json.load(f)
f.close()
try: try:
apiKey = str(setting['apiKey']) apiKey = str(setting['apiKey'])
apiSecret = str(setting['apiSecret']) apiSecret = str(setting['apiSecret'])
@ -509,4 +510,4 @@ def printDict(d):
l.sort() l.sort()
for k in l: for k in l:
print(k, d[k]) print(k, d[k])

View File

@ -68,7 +68,7 @@ class BinanceGateway(VtGateway):
def connect(self): def connect(self):
"""连接""" """连接"""
try: try:
f = file(self.filePath) f = open(self.filePath)
except IOError: except IOError:
log = VtLogData() log = VtLogData()
log.gatewayName = self.gatewayName log.gatewayName = self.gatewayName
@ -78,6 +78,7 @@ class BinanceGateway(VtGateway):
# 解析json文件 # 解析json文件
setting = json.load(f) setting = json.load(f)
f.close()
try: try:
apiKey = str(setting['apiKey']) apiKey = str(setting['apiKey'])
secretKey = str(setting['secretKey']) secretKey = str(setting['secretKey'])
@ -487,4 +488,4 @@ class GatewayApi(BinanceApi):
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def cancel(self, cancelOrderReq): def cancel(self, cancelOrderReq):
"""""" """"""
self.cancelOrder(cancelOrderReq.symbol, origClientOrderId=cancelOrderReq.orderID) self.cancelOrder(cancelOrderReq.symbol, origClientOrderId=cancelOrderReq.orderID)

View File

@ -51,7 +51,7 @@ class BitfinexGateay(VtGateway):
def connect(self): def connect(self):
"""连接""" """连接"""
try: try:
f = file(self.filePath) f = open(self.filePath)
except IOError: except IOError:
log = VtLogData() log = VtLogData()
log.gatewayName = self.gatewayName log.gatewayName = self.gatewayName
@ -61,6 +61,7 @@ class BitfinexGateay(VtGateway):
# 解析json文件 # 解析json文件
setting = json.load(f) setting = json.load(f)
f.close()
try: try:
apiKey = str(setting['apiKey']) apiKey = str(setting['apiKey'])
secretKey = str(setting['secretKey']) secretKey = str(setting['secretKey'])

View File

@ -78,7 +78,7 @@ class BithumbGateway(VtGateway):
def connect(self): def connect(self):
"""连接""" """连接"""
try: try:
f = file(self.filePath) f = open(self.filePath)
except IOError: except IOError:
log = VtLogData() log = VtLogData()
log.gatewayName = self.gatewayName log.gatewayName = self.gatewayName
@ -88,6 +88,7 @@ class BithumbGateway(VtGateway):
# 解析json文件 # 解析json文件
setting = json.load(f) setting = json.load(f)
f.close()
try: try:
apiKey = str(setting['apiKey']) apiKey = str(setting['apiKey'])
apiSecret = str(setting['apiSecret']) apiSecret = str(setting['apiSecret'])

View File

@ -61,7 +61,7 @@ class BitmexGateway(VtGateway):
def connect(self): def connect(self):
"""连接""" """连接"""
try: try:
f = file(self.filePath) f = open(self.filePath)
except IOError: except IOError:
log = VtLogData() log = VtLogData()
log.gatewayName = self.gatewayName log.gatewayName = self.gatewayName
@ -71,6 +71,7 @@ class BitmexGateway(VtGateway):
# 解析json文件 # 解析json文件
setting = json.load(f) setting = json.load(f)
f.close()
try: try:
apiKey = str(setting['apiKey']) apiKey = str(setting['apiKey'])
apiSecret = str(setting['apiSecret']) apiSecret = str(setting['apiSecret'])
@ -531,4 +532,4 @@ def printDict(d):
l.sort() l.sort()
for k in l: for k in l:
print(k, d[k]) print(k, d[k])

View File

@ -59,7 +59,7 @@ class CcxtGateway(VtGateway):
def connect(self): def connect(self):
"""连接""" """连接"""
try: try:
f = file(self.filePath) f = open(self.filePath)
except IOError: except IOError:
log = VtLogData() log = VtLogData()
log.gatewayName = self.gatewayName log.gatewayName = self.gatewayName
@ -69,6 +69,7 @@ class CcxtGateway(VtGateway):
# 解析json文件 # 解析json文件
setting = json.load(f) setting = json.load(f)
f.close()
try: try:
exchange = str(setting['exchange']) exchange = str(setting['exchange'])
apiKey = str(setting['apiKey']) apiKey = str(setting['apiKey'])
@ -544,4 +545,4 @@ class CcxtApi(object):
"""""" """"""
self.qryDepth() self.qryDepth()
self.qryTicker() self.qryTicker()

View File

@ -58,7 +58,7 @@ class CoinbaseGateway(VtGateway):
def connect(self): def connect(self):
"""连接""" """连接"""
try: try:
f = file(self.filePath) f = open(self.filePath)
except IOError: except IOError:
log = VtLogData() log = VtLogData()
log.gatewayName = self.gatewayName log.gatewayName = self.gatewayName
@ -68,6 +68,7 @@ class CoinbaseGateway(VtGateway):
# 解析json文件 # 解析json文件
setting = json.load(f) setting = json.load(f)
f.close()
try: try:
apiKey = str(setting['apiKey']) apiKey = str(setting['apiKey'])
secretKey = str(setting['secretKey']) secretKey = str(setting['secretKey'])
@ -661,4 +662,4 @@ def printDict(d):
l.sort() l.sort()
for k in l: for k in l:
print(k, d[k]) print(k, d[k])

View File

@ -104,7 +104,7 @@ class CshshlpGateway(VtGateway):
"""连接""" """连接"""
# 载入json文件 # 载入json文件
try: try:
f = file(self.filePath) f = open(self.filePath)
except IOError: except IOError:
log = VtLogData() log = VtLogData()
log.gatewayName = self.gatewayName log.gatewayName = self.gatewayName
@ -114,6 +114,7 @@ class CshshlpGateway(VtGateway):
# 解析json文件 # 解析json文件
setting = json.load(f) setting = json.load(f)
f.close()
try: try:
userID = str(setting['userID']) userID = str(setting['userID'])

View File

@ -60,7 +60,7 @@ class FcoinGateway(VtGateway):
def connect(self): def connect(self):
"""连接""" """连接"""
try: try:
f = file(self.filePath) f = open(self.filePath)
except IOError: except IOError:
log = VtLogData() log = VtLogData()
log.gatewayName = self.gatewayName log.gatewayName = self.gatewayName
@ -70,6 +70,7 @@ class FcoinGateway(VtGateway):
# 解析json文件 # 解析json文件
setting = json.load(f) setting = json.load(f)
f.close()
try: try:
apiKey = str(setting['apiKey']) apiKey = str(setting['apiKey'])
apiSecret = str(setting['apiSecret']) apiSecret = str(setting['apiSecret'])
@ -579,4 +580,4 @@ def printDict(d):
l.sort() l.sort()
for k in l: for k in l:
print(k, d[k]) print(k, d[k])

View File

@ -81,7 +81,7 @@ class FemasGateway(VtGateway):
"""连接""" """连接"""
# 载入json文件 # 载入json文件
try: try:
f = file(self.filePath) f = open(self.filePath)
except IOError: except IOError:
log = VtLogData() log = VtLogData()
log.gatewayName = self.gatewayName log.gatewayName = self.gatewayName
@ -91,6 +91,7 @@ class FemasGateway(VtGateway):
# 解析json文件 # 解析json文件
setting = json.load(f) setting = json.load(f)
f.close()
try: try:
userID = str(setting['userID']) userID = str(setting['userID'])
password = str(setting['password']) password = str(setting['password'])
@ -944,4 +945,4 @@ class FemasTdApi(TdApi):
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def onRspQryInvestorMargin(self, data, error, n, last): def onRspQryInvestorMargin(self, data, error, n, last):
"""""" """"""
pass pass

View File

@ -61,7 +61,7 @@ class FxcmGateway(VtGateway):
"""连接""" """连接"""
# 载入json文件 # 载入json文件
try: try:
f = file(self.filePath) f = open(self.filePath)
except IOError: except IOError:
log = VtLogData() log = VtLogData()
log.gatewayName = self.gatewayName log.gatewayName = self.gatewayName
@ -71,6 +71,7 @@ class FxcmGateway(VtGateway):
# 解析json文件 # 解析json文件
setting = json.load(f) setting = json.load(f)
f.close()
try: try:
port = int(setting['port']) port = int(setting['port'])
url = str(setting['url']) url = str(setting['url'])
@ -564,4 +565,4 @@ def getTime(s):
t = ':'.join([hour, minute, second]) t = ':'.join([hour, minute, second])
d = ''.join([year, month, day]) d = ''.join([year, month, day])
return d, t return d, t

View File

@ -149,7 +149,7 @@ class IbGateway(VtGateway):
"""连接""" """连接"""
# 载入json文件 # 载入json文件
try: try:
f = file(self.filePath) f = open(self.filePath)
except IOError: except IOError:
log = VtLogData() log = VtLogData()
log.gatewayName = self.gatewayName log.gatewayName = self.gatewayName
@ -159,6 +159,7 @@ class IbGateway(VtGateway):
# 解析json文件 # 解析json文件
setting = json.load(f) setting = json.load(f)
f.close()
try: try:
self.host = str(setting['host']) self.host = str(setting['host'])
self.port = int(setting['port']) self.port = int(setting['port'])
@ -737,4 +738,4 @@ class IbWrapper(IbApi):
def softDollarTiers(self, reqId, tiers): def softDollarTiers(self, reqId, tiers):
"""""" """"""
pass pass

View File

@ -54,7 +54,7 @@ class KsgoldGateway(VtGateway):
"""连接""" """连接"""
# 载入json文件 # 载入json文件
try: try:
f = file(self.filePath) f = open(self.filePath)
except IOError: except IOError:
log = VtLogData() log = VtLogData()
log.gatewayName = self.gatewayName log.gatewayName = self.gatewayName
@ -64,6 +64,7 @@ class KsgoldGateway(VtGateway):
# 解析json文件 # 解析json文件
setting = json.load(f) setting = json.load(f)
f.close()
try: try:
accountID = str(setting['accountID']) accountID = str(setting['accountID'])
password = str(setting['password']) password = str(setting['password'])

View File

@ -76,7 +76,7 @@ class KsotpGateway(VtGateway):
"""连接""" """连接"""
# 载入json文件 # 载入json文件
try: try:
f = file(self.filePath) f = open(self.filePath)
except IOError: except IOError:
log = VtLogData() log = VtLogData()
log.gatewayName = self.gatewayName log.gatewayName = self.gatewayName
@ -86,6 +86,7 @@ class KsotpGateway(VtGateway):
# 解析json文件 # 解析json文件
setting = json.load(f) setting = json.load(f)
f.close()
try: try:
userID = str(setting['userID']) userID = str(setting['userID'])
password = str(setting['password']) password = str(setting['password'])

View File

@ -50,7 +50,7 @@ class LbankGateway(VtGateway):
def connect(self): def connect(self):
"""连接""" """连接"""
try: try:
f = file(self.filePath) f = open(self.filePath)
except IOError: except IOError:
log = VtLogData() log = VtLogData()
log.gatewayName = self.gatewayName log.gatewayName = self.gatewayName
@ -60,6 +60,7 @@ class LbankGateway(VtGateway):
# 解析json文件 # 解析json文件
setting = json.load(f) setting = json.load(f)
f.close()
try: try:
apiKey = str(setting['apiKey']) apiKey = str(setting['apiKey'])
secretKey = str(setting['secretKey']) secretKey = str(setting['secretKey'])

View File

@ -78,7 +78,7 @@ class LtsGateway(VtGateway):
"""连接""" """连接"""
# 载入json 文件 # 载入json 文件
try: try:
f = file(self.filePath) f = open(self.filePath)
except IOError: except IOError:
log = VtLogData() log = VtLogData()
log.gatewayName = self.gatewayName log.gatewayName = self.gatewayName
@ -88,6 +88,7 @@ class LtsGateway(VtGateway):
# 解析json文件 # 解析json文件
setting = json.load(f) setting = json.load(f)
f.close()
try: try:
userID = str(setting['userID']) userID = str(setting['userID'])
mdPassword = str(setting['mdPassword']) mdPassword = str(setting['mdPassword'])
@ -1239,4 +1240,4 @@ class LtsQryApi(QryApi):
self.exit() self.exit()

View File

@ -63,7 +63,7 @@ class OkexGateway(VtGateway):
"""连接""" """连接"""
# 载入json文件 # 载入json文件
try: try:
f = file(self.filePath) f = open(self.filePath)
except IOError: except IOError:
log = VtLogData() log = VtLogData()
log.gatewayName = self.gatewayName log.gatewayName = self.gatewayName
@ -73,6 +73,7 @@ class OkexGateway(VtGateway):
# 解析json文件 # 解析json文件
setting = json.load(f) setting = json.load(f)
f.close()
try: try:
apiKey = str(setting['apiKey']) apiKey = str(setting['apiKey'])
secretKey = str(setting['secretKey']) secretKey = str(setting['secretKey'])
@ -628,4 +629,4 @@ class SpotApi(OkexSpotApi):
self.subscribeSpotDepth(symbol, 5) self.subscribeSpotDepth(symbol, 5)
self.subSpotOrder(symbol) self.subSpotOrder(symbol)
self.subSpotBalance(symbol) self.subSpotBalance(symbol)

View File

@ -85,7 +85,7 @@ class QdpGateway(VtGateway):
def connect(self): def connect(self):
"""连接""" """连接"""
try: try:
f = file(self.filePath) f = open(self.filePath)
except IOError: except IOError:
log = VtLogData() log = VtLogData()
log.gatewayName = self.gatewayName log.gatewayName = self.gatewayName
@ -95,6 +95,7 @@ class QdpGateway(VtGateway):
# 解析json文件 # 解析json文件
setting = json.load(f) setting = json.load(f)
f.close()
try: try:
userID = str(setting['userID']) userID = str(setting['userID'])
password = str(setting['password']) password = str(setting['password'])

View File

@ -82,7 +82,7 @@ class SecGateway(VtGateway):
def connect(self): def connect(self):
"""连接""" """连接"""
try: try:
f = file(self.filePath) f = open(self.filePath)
except IOError: except IOError:
log = VtLogData() log = VtLogData()
log.gatewayName = self.gatewayName log.gatewayName = self.gatewayName
@ -92,6 +92,7 @@ class SecGateway(VtGateway):
# 解析json文件 # 解析json文件
setting = json.load(f) setting = json.load(f)
f.close()
try: try:
accountID = str(setting['accountID']) accountID = str(setting['accountID'])
password = str(setting['password']) password = str(setting['password'])
@ -1587,4 +1588,4 @@ def checkOptionSymbol(symbol):
if len(symbol) > 6: if len(symbol) > 6:
return True return True
return False return False

View File

@ -96,7 +96,7 @@ class SgitGateway(VtGateway):
def connect(self): def connect(self):
"""连接""" """连接"""
try: try:
f = file(self.filePath) f = open(self.filePath)
except IOError: except IOError:
log = VtLogData() log = VtLogData()
log.gatewayName = self.gatewayName log.gatewayName = self.gatewayName
@ -106,6 +106,7 @@ class SgitGateway(VtGateway):
# 解析json文件 # 解析json文件
setting = json.load(f) setting = json.load(f)
f.close()
try: try:
userID = str(setting['userID']) userID = str(setting['userID'])
password = str(setting['password']) password = str(setting['password'])
@ -1405,4 +1406,4 @@ class PositionBuffer(object):
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def getPos(self): def getPos(self):
"""获取当前的持仓数据""" """获取当前的持仓数据"""
return copy(self.pos) return copy(self.pos)

View File

@ -77,7 +77,7 @@ class ShzdGateway(VtGateway):
def connect(self): def connect(self):
"""连接""" """连接"""
try: try:
f = file(self.filePath) f = open(self.filePath)
except IOError: except IOError:
log = VtLogData() log = VtLogData()
log.gatewayName = self.gatewayName log.gatewayName = self.gatewayName
@ -87,6 +87,7 @@ class ShzdGateway(VtGateway):
# 解析json文件 # 解析json文件
setting = json.load(f) setting = json.load(f)
f.close()
try: try:
frontAddress = str(setting['frontAddress']) frontAddress = str(setting['frontAddress'])
frontPort = int(setting['frontPort']) frontPort = int(setting['frontPort'])
@ -727,4 +728,4 @@ def printDict(d):
l.sort() l.sort()
for k in l: for k in l:
print(k, ':', d[k]) print(k, ':', d[k])

View File

@ -86,7 +86,7 @@ class XspeedGateway(VtGateway):
def connect(self): def connect(self):
"""连接""" """连接"""
try: try:
f = file(self.filePath) f = open(self.filePath)
except IOError: except IOError:
log = VtLogData() log = VtLogData()
log.gatewayName = self.gatewayName log.gatewayName = self.gatewayName
@ -96,6 +96,7 @@ class XspeedGateway(VtGateway):
# 解析json文件 # 解析json文件
setting = json.load(f) setting = json.load(f)
f.close()
try: try:
accountID = str(setting['accountID']) accountID = str(setting['accountID'])
password = str(setting['password']) password = str(setting['password'])
@ -1220,4 +1221,4 @@ class XspeedTdApi(TdApi):
def onRspEquityComputMode(self, data) : def onRspEquityComputMode(self, data) :
"""""" """"""
pass pass

View File

@ -111,7 +111,7 @@ class XtpGateway(VtGateway):
def connect(self): def connect(self):
"""连接""" """连接"""
try: try:
f = file(self.filePath) f = open(self.filePath)
except IOError: except IOError:
log = VtLogData() log = VtLogData()
log.gatewayName = self.gatewayName log.gatewayName = self.gatewayName
@ -120,7 +120,8 @@ class XtpGateway(VtGateway):
return return
# 解析json文件 # 解析json文件
setting = json.load(f) setting = json.load(f)
f.close()
try: try:
userID = str(setting['userID']) userID = str(setting['userID'])
password = str(setting['password']) password = str(setting['password'])
@ -823,4 +824,4 @@ class XtpTdApi(TraderApi):
log = VtLogData() log = VtLogData()
log.gatewayName = self.gatewayName log.gatewayName = self.gatewayName
log.logContent = content log.logContent = content
self.gateway.onLog(log) self.gateway.onLog(log)