Merge pull request #1250 from vnpy/dev

v1.9.1发布前最后修改
This commit is contained in:
vn.py 2018-11-18 20:27:50 +08:00 committed by GitHub
commit ac626fd6f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 4 deletions

View File

@ -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
#---------------------------------------------------------------------- #----------------------------------------------------------------------

View File

@ -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) # 加载同步数据后再订阅行情

View File

@ -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)