From 0e5edd08e5f34898f8d17558bdcf1992a4d1256d Mon Sep 17 00:00:00 2001 From: Eoin Date: Wed, 27 Sep 2017 23:43:32 +0100 Subject: [PATCH 1/2] add dataframe empty check --- analyze.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/analyze.py b/analyze.py index 338549c87..51e84c6cd 100644 --- a/analyze.py +++ b/analyze.py @@ -96,6 +96,11 @@ def analyze_ticker(pair: str) -> DataFrame: minimum_date = arrow.utcnow().shift(hours=-6) data = get_ticker(pair, minimum_date) dataframe = parse_ticker_dataframe(data['result'], minimum_date) + + if dataframe.empty: + logger.debug('Empty dataframe for pair %s', pair) + return dataframe + dataframe = populate_indicators(dataframe) dataframe = populate_buy_trend(dataframe) return dataframe @@ -107,6 +112,10 @@ def get_buy_signal(pair: str) -> bool: :return: True if pair is good for buying, False otherwise """ dataframe = analyze_ticker(pair) + + if dataframe.empty: + return False + latest = dataframe.iloc[-1] # Check if dataframe is out of date From a45073997de3285af4da103982e50cf60e1203ee Mon Sep 17 00:00:00 2001 From: Eoin Date: Thu, 28 Sep 2017 20:07:33 +0100 Subject: [PATCH 2/2] review comments: change log to warning --- analyze.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/analyze.py b/analyze.py index 51e84c6cd..f344f047a 100644 --- a/analyze.py +++ b/analyze.py @@ -98,7 +98,7 @@ def analyze_ticker(pair: str) -> DataFrame: dataframe = parse_ticker_dataframe(data['result'], minimum_date) if dataframe.empty: - logger.debug('Empty dataframe for pair %s', pair) + logger.warning('Empty dataframe for pair %s', pair) return dataframe dataframe = populate_indicators(dataframe)