add three triggers to hyperopting
This commit is contained in:
parent
09261b11af
commit
136456afc0
@ -94,6 +94,7 @@ class Hyperopt(Backtesting):
|
|||||||
# Bollinger bands
|
# Bollinger bands
|
||||||
bollinger = qtpylib.bollinger_bands(qtpylib.typical_price(dataframe), window=20, stds=2)
|
bollinger = qtpylib.bollinger_bands(qtpylib.typical_price(dataframe), window=20, stds=2)
|
||||||
dataframe['bb_lowerband'] = bollinger['lower']
|
dataframe['bb_lowerband'] = bollinger['lower']
|
||||||
|
dataframe['sar'] = ta.SAR(dataframe)
|
||||||
|
|
||||||
return dataframe
|
return dataframe
|
||||||
|
|
||||||
@ -204,6 +205,7 @@ class Hyperopt(Backtesting):
|
|||||||
Categorical([True, False], name='fastd-enabled'),
|
Categorical([True, False], name='fastd-enabled'),
|
||||||
Categorical([True, False], name='adx-enabled'),
|
Categorical([True, False], name='adx-enabled'),
|
||||||
Categorical([True, False], name='rsi-enabled'),
|
Categorical([True, False], name='rsi-enabled'),
|
||||||
|
Categorical(['bb_lower', 'macd_cross_signal', 'sar_reversal'], name='trigger')
|
||||||
]
|
]
|
||||||
|
|
||||||
def has_space(self, space: str) -> bool:
|
def has_space(self, space: str) -> bool:
|
||||||
@ -238,8 +240,6 @@ class Hyperopt(Backtesting):
|
|||||||
"""
|
"""
|
||||||
conditions = []
|
conditions = []
|
||||||
# GUARDS AND TRENDS
|
# GUARDS AND TRENDS
|
||||||
# if 'macd_below_zero' in params and params['macd_below_zero']['enabled']:
|
|
||||||
# conditions.append(dataframe['macd'] < 0)
|
|
||||||
if 'mfi-enabled' in params and params['mfi-enabled']:
|
if 'mfi-enabled' in params and params['mfi-enabled']:
|
||||||
conditions.append(dataframe['mfi'] < params['mfi-value'])
|
conditions.append(dataframe['mfi'] < params['mfi-value'])
|
||||||
if 'fastd' in params and params['fastd-enabled']:
|
if 'fastd' in params and params['fastd-enabled']:
|
||||||
@ -250,11 +250,16 @@ class Hyperopt(Backtesting):
|
|||||||
conditions.append(dataframe['rsi'] < params['rsi-value'])
|
conditions.append(dataframe['rsi'] < params['rsi-value'])
|
||||||
|
|
||||||
# TRIGGERS
|
# TRIGGERS
|
||||||
triggers = {
|
if params['trigger'] == 'bb_lower':
|
||||||
}
|
conditions.append(dataframe['close'] < dataframe['bb_lowerband'])
|
||||||
#conditions.append(triggers.get(params['trigger']['type']))
|
if params['trigger'] == 'macd_cross_signal':
|
||||||
|
conditions.append(qtpylib.crossed_above(
|
||||||
conditions.append(dataframe['close'] < dataframe['bb_lowerband']) # single trigger
|
dataframe['macd'], dataframe['macdsignal']
|
||||||
|
))
|
||||||
|
if params['trigger'] == 'sar_reversal':
|
||||||
|
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),
|
||||||
|
Loading…
Reference in New Issue
Block a user