add dataframe empty check

This commit is contained in:
Eoin 2017-09-27 23:43:32 +01:00
parent 2bd51d8be3
commit 0e5edd08e5

View File

@ -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