commit
ac626fd6f7
@ -6,6 +6,7 @@ import ssl
|
||||
import hashlib
|
||||
import json
|
||||
import traceback
|
||||
import zlib
|
||||
from threading import Thread
|
||||
from time import sleep
|
||||
|
||||
@ -145,7 +146,13 @@ class OkexApi(object):
|
||||
#----------------------------------------------------------------------
|
||||
def readData(self, evt):
|
||||
"""解码推送收到的数据"""
|
||||
data = json.loads(evt)
|
||||
# 先解压
|
||||
decompress = zlib.decompressobj(-zlib.MAX_WBITS)
|
||||
inflated = decompress.decompress(evt)
|
||||
inflated += decompress.flush()
|
||||
|
||||
# 再转换为json
|
||||
data = json.loads(inflated)
|
||||
return data
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
@ -441,9 +441,9 @@ class CtaEngine(AppEngine):
|
||||
strategy = self.strategyDict[name]
|
||||
|
||||
if not strategy.inited:
|
||||
self.callStrategyFunc(strategy, strategy.onInit)
|
||||
strategy.inited = True
|
||||
|
||||
self.callStrategyFunc(strategy, strategy.onInit)
|
||||
|
||||
self.loadSyncData(strategy) # 初始化完成后加载同步数据
|
||||
self.subscribeMarketData(strategy) # 加载同步数据后再订阅行情
|
||||
else:
|
||||
|
@ -700,7 +700,7 @@ class LogEngine(object):
|
||||
if not filename:
|
||||
filename = 'vt_' + datetime.now().strftime('%Y%m%d') + '.log'
|
||||
filepath = getTempPath(filename)
|
||||
self.fileHandler = logging.FileHandler(filepath)
|
||||
self.fileHandler = logging.FileHandler(filepath, mode='w', encoding='utf-8')
|
||||
self.fileHandler.setLevel(self.level)
|
||||
self.fileHandler.setFormatter(self.formatter)
|
||||
self.logger.addHandler(self.fileHandler)
|
||||
|
Loading…
Reference in New Issue
Block a user