add macd < 0 guard to hyperopt

This commit is contained in:
Janne Sinivirta 2018-01-16 13:31:45 +02:00
parent dc01807b3c
commit ce963aae58
2 changed files with 8 additions and 1 deletions

View File

@ -58,6 +58,10 @@ main._CONF = OPTIMIZE_CONFIG
SPACE = { SPACE = {
'macd_below_zero': hp.choice('macd_below_zero', [
{'enabled': False},
{'enabled': True}
]),
'mfi': hp.choice('mfi', [ 'mfi': hp.choice('mfi', [
{'enabled': False}, {'enabled': False},
{'enabled': True, 'value': hp.quniform('mfi-value', 5, 25, 1)} {'enabled': True, 'value': hp.quniform('mfi-value', 5, 25, 1)}
@ -207,6 +211,8 @@ def buy_strategy_generator(params):
# GUARDS AND TRENDS # GUARDS AND TRENDS
if params['uptrend_long_ema']['enabled']: if params['uptrend_long_ema']['enabled']:
conditions.append(dataframe['ema50'] > dataframe['ema100']) conditions.append(dataframe['ema50'] > dataframe['ema100'])
if params['macd_below_zero']['enabled']:
conditions.append(dataframe['macd'] < 0)
if params['uptrend_short_ema']['enabled']: if params['uptrend_short_ema']['enabled']:
conditions.append(dataframe['ema5'] > dataframe['ema10']) conditions.append(dataframe['ema5'] > dataframe['ema10'])
if params['mfi']['enabled']: if params['mfi']['enabled']:

View File

@ -107,6 +107,7 @@ def test_no_log_if_loss_does_not_improve(mocker):
def test_fmin_best_results(mocker, caplog): def test_fmin_best_results(mocker, caplog):
fmin_result = { fmin_result = {
"macd_below_zero": 0,
"adx": 1, "adx": 1,
"adx-value": 15.0, "adx-value": 15.0,
"fastd": 1, "fastd": 1,
@ -136,7 +137,7 @@ def test_fmin_best_results(mocker, caplog):
'"adx": {\n "enabled": true,\n "value": 15.0\n },', '"adx": {\n "enabled": true,\n "value": 15.0\n },',
'"green_candle": {\n "enabled": true\n },', '"green_candle": {\n "enabled": true\n },',
'"mfi": {\n "enabled": false\n },', '"mfi": {\n "enabled": false\n },',
'"trigger": {\n "type": "ao_cross_zero"\n },', '"trigger": {\n "type": "faststoch10"\n },',
'"stoploss": -0.1', '"stoploss": -0.1',
] ]