diff --git a/vnpy/api/okex/vnokex.py b/vnpy/api/okex/vnokex.py index 7d769b31..4e65c959 100644 --- a/vnpy/api/okex/vnokex.py +++ b/vnpy/api/okex/vnokex.py @@ -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 #----------------------------------------------------------------------