commit
ac626fd6f7
@ -6,6 +6,7 @@ import ssl
|
|||||||
import hashlib
|
import hashlib
|
||||||
import json
|
import json
|
||||||
import traceback
|
import traceback
|
||||||
|
import zlib
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
@ -145,7 +146,13 @@ class OkexApi(object):
|
|||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def readData(self, evt):
|
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
|
return data
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
|
@ -441,8 +441,8 @@ class CtaEngine(AppEngine):
|
|||||||
strategy = self.strategyDict[name]
|
strategy = self.strategyDict[name]
|
||||||
|
|
||||||
if not strategy.inited:
|
if not strategy.inited:
|
||||||
self.callStrategyFunc(strategy, strategy.onInit)
|
|
||||||
strategy.inited = True
|
strategy.inited = True
|
||||||
|
self.callStrategyFunc(strategy, strategy.onInit)
|
||||||
|
|
||||||
self.loadSyncData(strategy) # 初始化完成后加载同步数据
|
self.loadSyncData(strategy) # 初始化完成后加载同步数据
|
||||||
self.subscribeMarketData(strategy) # 加载同步数据后再订阅行情
|
self.subscribeMarketData(strategy) # 加载同步数据后再订阅行情
|
||||||
|
@ -700,7 +700,7 @@ class LogEngine(object):
|
|||||||
if not filename:
|
if not filename:
|
||||||
filename = 'vt_' + datetime.now().strftime('%Y%m%d') + '.log'
|
filename = 'vt_' + datetime.now().strftime('%Y%m%d') + '.log'
|
||||||
filepath = getTempPath(filename)
|
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.setLevel(self.level)
|
||||||
self.fileHandler.setFormatter(self.formatter)
|
self.fileHandler.setFormatter(self.formatter)
|
||||||
self.logger.addHandler(self.fileHandler)
|
self.logger.addHandler(self.fileHandler)
|
||||||
|
Loading…
Reference in New Issue
Block a user