From 6312732255c10f00bc290c33da1b56d9e104362f Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 2 Aug 2020 11:01:27 +0200 Subject: [PATCH] Add volume > 0 check --- user_data/hyperopts/AverageHyperopt.py | 3 +++ user_data/hyperopts/MACDStrategy_hyperopt.py | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/user_data/hyperopts/AverageHyperopt.py b/user_data/hyperopts/AverageHyperopt.py index 0e6797b..75b5f95 100644 --- a/user_data/hyperopts/AverageHyperopt.py +++ b/user_data/hyperopts/AverageHyperopt.py @@ -48,6 +48,9 @@ class AverageHyperopt(IHyperOpt): dataframe[f"maMedium({params['trigger'][1]})"]) ) + # Check that volume is not 0 + conditions.append(dataframe['volume'] > 0) + if conditions: dataframe.loc[ reduce(lambda x, y: x & y, conditions), diff --git a/user_data/hyperopts/MACDStrategy_hyperopt.py b/user_data/hyperopts/MACDStrategy_hyperopt.py index d10b566..473e9c6 100644 --- a/user_data/hyperopts/MACDStrategy_hyperopt.py +++ b/user_data/hyperopts/MACDStrategy_hyperopt.py @@ -52,7 +52,8 @@ class MACDStrategy_hyperopt(IHyperOpt): dataframe.loc[ ( (dataframe['macd'] > dataframe['macdsignal']) & - (dataframe['cci'] <= params['buy-cci-value']) + (dataframe['cci'] <= params['buy-cci-value']) & + (dataframe['volume'] > 0) # Make sure Volume is not 0 ), 'buy'] = 1