From 4229f6e210771bde48ac96274f0df5ef66d378a6 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Sat, 17 Nov 2018 09:53:14 +0800 Subject: [PATCH] [Fix]Close #1239 --- vnpy/api/okex/vnokex.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 #----------------------------------------------------------------------