Avoid hyperopt to fail if a guard was removed from SPACE but still defined in populate_buy_trend()

This commit is contained in:
Gerald Lonlas 2018-01-18 21:25:14 -08:00
parent 1c7da95fed
commit 3e8088d99c

View File

@ -305,25 +305,25 @@ class DefaultStrategy(IStrategy):
def populate_buy_trend(dataframe: DataFrame) -> DataFrame: def populate_buy_trend(dataframe: DataFrame) -> DataFrame:
conditions = [] conditions = []
# GUARDS AND TRENDS # GUARDS AND TRENDS
if params['uptrend_long_ema']['enabled']: if 'uptrend_long_ema' in params and params['uptrend_long_ema']['enabled']:
conditions.append(dataframe['ema50'] > dataframe['ema100']) conditions.append(dataframe['ema50'] > dataframe['ema100'])
if params['macd_below_zero']['enabled']: if 'macd_below_zero' in params and params['macd_below_zero']['enabled']:
conditions.append(dataframe['macd'] < 0) conditions.append(dataframe['macd'] < 0)
if params['uptrend_short_ema']['enabled']: if 'uptrend_short_ema' in params and params['uptrend_short_ema']['enabled']:
conditions.append(dataframe['ema5'] > dataframe['ema10']) conditions.append(dataframe['ema5'] > dataframe['ema10'])
if params['mfi']['enabled']: if 'mfi' in params and params['mfi']['enabled']:
conditions.append(dataframe['mfi'] < params['mfi']['value']) conditions.append(dataframe['mfi'] < params['mfi']['value'])
if params['fastd']['enabled']: if 'fastd' in params and params['fastd']['enabled']:
conditions.append(dataframe['fastd'] < params['fastd']['value']) conditions.append(dataframe['fastd'] < params['fastd']['value'])
if params['adx']['enabled']: if 'adx' in params and params['adx']['enabled']:
conditions.append(dataframe['adx'] > params['adx']['value']) conditions.append(dataframe['adx'] > params['adx']['value'])
if params['rsi']['enabled']: if 'rsi' in params and params['rsi']['enabled']:
conditions.append(dataframe['rsi'] < params['rsi']['value']) conditions.append(dataframe['rsi'] < params['rsi']['value'])
if params['over_sar']['enabled']: if 'over_sar' in params and params['over_sar']['enabled']:
conditions.append(dataframe['close'] > dataframe['sar']) conditions.append(dataframe['close'] > dataframe['sar'])
if params['green_candle']['enabled']: if 'green_candle' in params and params['green_candle']['enabled']:
conditions.append(dataframe['close'] > dataframe['open']) conditions.append(dataframe['close'] > dataframe['open'])
if params['uptrend_sma']['enabled']: if 'uptrend_sma' in params and params['uptrend_sma']['enabled']:
prevsma = dataframe['sma'].shift(1) prevsma = dataframe['sma'].shift(1)
conditions.append(dataframe['sma'] > prevsma) conditions.append(dataframe['sma'] > prevsma)