From 2972908cb99d456a841afd5b311393dd280e2649 Mon Sep 17 00:00:00 2001 From: wassname Date: Fri, 10 Nov 2017 11:03:23 +0800 Subject: [PATCH] handle no data being returned without exception --- libcryptomarket/historical.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libcryptomarket/historical.py b/libcryptomarket/historical.py index 410f79d..e6eb121 100644 --- a/libcryptomarket/historical.py +++ b/libcryptomarket/historical.py @@ -85,9 +85,12 @@ def get_historical_prices(source='cryptocompare', symbol=None, exchange=None, else: data += func()['Data'] + if len(data) == 0: + return data + data = pd.DataFrame([CryptocompareHisto(**e).__dict__ for e in data]) # Filter only valid time range - if len(data) and from_time is not None and to_time is not None: + if from_time is not None and to_time is not None: data = data[(data['r_time'] >= from_time) & (data['r_time'] <= to_time)]