Merge pull request #30 from freshfunkee/feature/handle-empty-dataframe

dataframe empty check
This commit is contained in:
Michael Egger 2017-09-28 21:49:06 +02:00 committed by GitHub
commit 3b9d354a62

View File

@ -96,6 +96,11 @@ def analyze_ticker(pair: str) -> DataFrame:
minimum_date = arrow.utcnow().shift(hours=-6) minimum_date = arrow.utcnow().shift(hours=-6)
data = get_ticker(pair, minimum_date) data = get_ticker(pair, minimum_date)
dataframe = parse_ticker_dataframe(data['result'], minimum_date) dataframe = parse_ticker_dataframe(data['result'], minimum_date)
if dataframe.empty:
logger.warning('Empty dataframe for pair %s', pair)
return dataframe
dataframe = populate_indicators(dataframe) dataframe = populate_indicators(dataframe)
dataframe = populate_buy_trend(dataframe) dataframe = populate_buy_trend(dataframe)
return dataframe return dataframe
@ -107,6 +112,10 @@ def get_buy_signal(pair: str) -> bool:
:return: True if pair is good for buying, False otherwise :return: True if pair is good for buying, False otherwise
""" """
dataframe = analyze_ticker(pair) dataframe = analyze_ticker(pair)
if dataframe.empty:
return False
latest = dataframe.iloc[-1] latest = dataframe.iloc[-1]
# Check if dataframe is out of date # Check if dataframe is out of date