From 374c228ebf2f2b8d75f0dad3a3af711d4f80d090 Mon Sep 17 00:00:00 2001 From: yangyang Date: Thu, 31 Aug 2017 15:02:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=95=B0=E6=8D=AE=E5=BA=8F?= =?UTF-8?q?=E5=88=97=E4=B8=BA=E7=A9=BA=E6=97=B6=E6=8A=A5=E9=94=99=E7=9A=84?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/data/tq/vntq.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/vnpy/data/tq/vntq.py b/vnpy/data/tq/vntq.py index ba91c0f3..b630b809 100644 --- a/vnpy/data/tq/vntq.py +++ b/vnpy/data/tq/vntq.py @@ -226,11 +226,12 @@ class TqApi(object): chart_id = self._generate_chart_id(ins_id, 0) sub_info = self.chart_subscribes.get(chart_id) tick_serial = self.get_tick_serial(ins_id) - while len(tick_serial) > sub_info["view_width"]: - tick_serial.popitem(last=False) - callback_func = sub_info["callback"] - if callback_func: - callback_func(ins_id, 0) + if tick_serial: + while len(tick_serial) > sub_info["view_width"]: + tick_serial.popitem(last=False) + callback_func = sub_info["callback"] + if callback_func: + callback_func(ins_id, 0) elif selector == "klines": for ins_id, sub_section in section.items(): @@ -239,11 +240,12 @@ class TqApi(object): chart_id = self._generate_chart_id(ins_id, dur_seconds) sub_info = self.chart_subscribes.get(chart_id) kline_serial = self.get_kline_serial(ins_id, dur_seconds) - while len(kline_serial) > sub_info["view_width"]: - kline_serial.popitem(last=False) - callback_func = sub_info["callback"] - if callback_func: - callback_func(ins_id, dur_seconds) + if kline_serial: + while len(kline_serial) > sub_info["view_width"]: + kline_serial.popitem(last=False) + callback_func = sub_info["callback"] + if callback_func: + callback_func(ins_id, dur_seconds) #---------------------------------------------------------------------- def _merge_obj(self, result, obj):