From 9557534eaf3709d90ea2197e75b60998a24aa7f4 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Thu, 9 May 2019 13:41:40 +0800 Subject: [PATCH] [Add] write log and return if no data feteched --- vnpy/gateway/bitmex/bitmex_gateway.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/vnpy/gateway/bitmex/bitmex_gateway.py b/vnpy/gateway/bitmex/bitmex_gateway.py index cb815936..e8248f29 100644 --- a/vnpy/gateway/bitmex/bitmex_gateway.py +++ b/vnpy/gateway/bitmex/bitmex_gateway.py @@ -331,9 +331,13 @@ class BitmexRestApi(RestClient): break else: data = resp.json() + if not data: + msg = f"获取历史数据为空,开始时间:{start_time},数量:{count}" + break for d in data: - dt = datetime.strptime(d["timestamp"], "%Y-%m-%dT%H:%M:%S.%fZ") + dt = datetime.strptime( + d["timestamp"], "%Y-%m-%dT%H:%M:%S.%fZ") bar = BarData( symbol=req.symbol, exchange=req.exchange, @@ -360,7 +364,7 @@ class BitmexRestApi(RestClient): # Update start time start_time = bar.datetime + TIMEDELTA_MAP[req.interval] - return history + return history def on_send_order_failed(self, status_code: str, request: Request): """