From 146c254c0fe6a6297561c165736e149af88fb9b4 Mon Sep 17 00:00:00 2001 From: Janne Sinivirta Date: Sat, 21 Oct 2017 10:26:38 +0300 Subject: [PATCH] start adding other triggers than just the lower BBands --- freqtrade/tests/test_hyperopt.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/freqtrade/tests/test_hyperopt.py b/freqtrade/tests/test_hyperopt.py index d0756b690..ad6c1d619 100644 --- a/freqtrade/tests/test_hyperopt.py +++ b/freqtrade/tests/test_hyperopt.py @@ -82,11 +82,11 @@ def buy_strategy_generator(params): print(params) def populate_buy_trend(dataframe: DataFrame) -> DataFrame: conditions = [] + # GUARDS AND TRENDS if params['below_sma']['enabled']: conditions.append(dataframe['close'] < dataframe['sma']) if params['over_sma']['enabled']: conditions.append(dataframe['close'] > dataframe['sma']) - conditions.append(dataframe['tema'] <= dataframe['blower']) if params['mfi']['enabled']: conditions.append(dataframe['mfi'] < params['mfi']['value']) if params['fastd']['enabled']: @@ -100,6 +100,15 @@ def buy_strategy_generator(params): if params['uptrend_sma']['enabled']: prevsma = dataframe['sma'].shift(1) conditions.append(dataframe['sma'] > prevsma) + + prev_fastd = dataframe['fastd'].shift(1) + # TRIGGERS + triggers = { + 'lower_bb': dataframe['tema'] <= dataframe['blower'], + 'faststoch10': (dataframe['fastd'] >= 10) & (prev_fastd < 10), + } + conditions.append(triggers.get(params['trigger']['type'])) + dataframe.loc[ reduce(lambda x, y: x & y, conditions), 'buy'] = 1 @@ -147,6 +156,10 @@ def test_hyperopt(conf, pairs, mocker): {'enabled': False}, {'enabled': True} ]), + 'trigger': hp.choice('trigger', [ + {'type': 'lower_bb'}, + {'type': 'faststoch10'} + ]), } # print(hyperopt.pyll.stochastic.sample(space))