Add check if trigger is in parameters

This commit is contained in:
Matthias 2019-01-06 10:30:58 +01:00
parent 5e08769366
commit 798ae460d8
3 changed files with 29 additions and 26 deletions

View File

@ -98,12 +98,13 @@ So let's write the buy strategy using these values:
conditions.append(dataframe['rsi'] < params['rsi-value']) conditions.append(dataframe['rsi'] < params['rsi-value'])
# TRIGGERS # TRIGGERS
if params['trigger'] == 'bb_lower': if 'trigger' in params:
conditions.append(dataframe['close'] < dataframe['bb_lowerband']) if params['trigger'] == 'bb_lower':
if params['trigger'] == 'macd_cross_signal': conditions.append(dataframe['close'] < dataframe['bb_lowerband'])
conditions.append(qtpylib.crossed_above( if params['trigger'] == 'macd_cross_signal':
dataframe['macd'], dataframe['macdsignal'] conditions.append(qtpylib.crossed_above(
)) dataframe['macd'], dataframe['macdsignal']
))
dataframe.loc[ dataframe.loc[
reduce(lambda x, y: x & y, conditions), reduce(lambda x, y: x & y, conditions),

View File

@ -57,16 +57,17 @@ class DefaultHyperOpts(IHyperOpt):
conditions.append(dataframe['rsi'] < params['rsi-value']) conditions.append(dataframe['rsi'] < params['rsi-value'])
# TRIGGERS # TRIGGERS
if params['trigger'] == 'bb_lower': if 'trigger' in params:
conditions.append(dataframe['close'] < dataframe['bb_lowerband']) if params['trigger'] == 'bb_lower':
if params['trigger'] == 'macd_cross_signal': conditions.append(dataframe['close'] < dataframe['bb_lowerband'])
conditions.append(qtpylib.crossed_above( if params['trigger'] == 'macd_cross_signal':
dataframe['macd'], dataframe['macdsignal'] conditions.append(qtpylib.crossed_above(
)) dataframe['macd'], dataframe['macdsignal']
if params['trigger'] == 'sar_reversal': ))
conditions.append(qtpylib.crossed_above( if params['trigger'] == 'sar_reversal':
dataframe['close'], dataframe['sar'] conditions.append(qtpylib.crossed_above(
)) dataframe['close'], dataframe['sar']
))
dataframe.loc[ dataframe.loc[
reduce(lambda x, y: x & y, conditions), reduce(lambda x, y: x & y, conditions),

View File

@ -66,16 +66,17 @@ class SampleHyperOpts(IHyperOpt):
conditions.append(dataframe['rsi'] < params['rsi-value']) conditions.append(dataframe['rsi'] < params['rsi-value'])
# TRIGGERS # TRIGGERS
if params['trigger'] == 'bb_lower': if 'trigger' in params:
conditions.append(dataframe['close'] < dataframe['bb_lowerband']) if params['trigger'] == 'bb_lower':
if params['trigger'] == 'macd_cross_signal': conditions.append(dataframe['close'] < dataframe['bb_lowerband'])
conditions.append(qtpylib.crossed_above( if params['trigger'] == 'macd_cross_signal':
dataframe['macd'], dataframe['macdsignal'] conditions.append(qtpylib.crossed_above(
)) dataframe['macd'], dataframe['macdsignal']
if params['trigger'] == 'sar_reversal': ))
conditions.append(qtpylib.crossed_above( if params['trigger'] == 'sar_reversal':
dataframe['close'], dataframe['sar'] conditions.append(qtpylib.crossed_above(
)) dataframe['close'], dataframe['sar']
))
dataframe.loc[ dataframe.loc[
reduce(lambda x, y: x & y, conditions), reduce(lambda x, y: x & y, conditions),