From 8644449c33b12f11d0f652ea309b8175481372bc Mon Sep 17 00:00:00 2001 From: Sam Germain Date: Sun, 22 Aug 2021 21:38:15 -0600 Subject: [PATCH] Removed changes from tests/strategy/strats that hyperopted short parameters, because these are supposed to be legacy tests --- tests/strategy/strats/default_strategy.py | 29 ------------ .../strategy/strats/hyperoptable_strategy.py | 44 ------------------- tests/strategy/strats/legacy_strategy.py | 1 - tests/strategy/test_interface.py | 7 ++- tests/strategy/test_strategy_loading.py | 4 -- 5 files changed, 3 insertions(+), 82 deletions(-) diff --git a/tests/strategy/strats/default_strategy.py b/tests/strategy/strats/default_strategy.py index be373e0ee..7171b93ae 100644 --- a/tests/strategy/strats/default_strategy.py +++ b/tests/strategy/strats/default_strategy.py @@ -130,19 +130,6 @@ class DefaultStrategy(IStrategy): ), 'buy'] = 1 - dataframe.loc[ - ( - (dataframe['rsi'] > 65) & - (dataframe['fastd'] > 65) & - (dataframe['adx'] < 70) & - (dataframe['plus_di'] < 0.5) # TODO-lev: What to do here - ) | - ( - (dataframe['adx'] < 35) & - (dataframe['plus_di'] < 0.5) # TODO-lev: What to do here - ), - 'enter_short'] = 1 - return dataframe def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: @@ -166,20 +153,4 @@ class DefaultStrategy(IStrategy): (dataframe['minus_di'] > 0.5) ), 'sell'] = 1 - - dataframe.loc[ - ( - ( - (qtpylib.crossed_below(dataframe['rsi'], 30)) | - (qtpylib.crossed_below(dataframe['fastd'], 30)) - ) & - (dataframe['adx'] < 90) & - (dataframe['minus_di'] < 0) # TODO-lev: what to do here - ) | - ( - (dataframe['adx'] > 30) & - (dataframe['minus_di'] < 0.5) # TODO-lev: what to do here - ), - 'exit_short'] = 1 - return dataframe diff --git a/tests/strategy/strats/hyperoptable_strategy.py b/tests/strategy/strats/hyperoptable_strategy.py index e45ba03f0..1126bd6cf 100644 --- a/tests/strategy/strats/hyperoptable_strategy.py +++ b/tests/strategy/strats/hyperoptable_strategy.py @@ -60,15 +60,6 @@ class HyperoptableStrategy(IStrategy): 'sell_minusdi': 0.4 } - enter_short_params = { - 'short_rsi': 65, - } - - exit_short_params = { - 'exit_short_rsi': 26, - 'exit_short_minusdi': 0.6 - } - buy_rsi = IntParameter([0, 50], default=30, space='buy') buy_plusdi = RealParameter(low=0, high=1, default=0.5, space='buy') sell_rsi = IntParameter(low=50, high=100, default=70, space='sell') @@ -87,12 +78,6 @@ class HyperoptableStrategy(IStrategy): }) return prot - enter_short_rsi = IntParameter([50, 100], default=70, space='sell') - enter_short_plusdi = RealParameter(low=0, high=1, default=0.5, space='sell') - exit_short_rsi = IntParameter(low=0, high=50, default=30, space='buy') - exit_short_minusdi = DecimalParameter(low=0, high=1, default=0.4999, decimals=3, space='buy', - load=False) - def informative_pairs(self): """ Define additional, informative pair/interval combinations to be cached from the exchange. @@ -175,19 +160,6 @@ class HyperoptableStrategy(IStrategy): ), 'buy'] = 1 - dataframe.loc[ - ( - (dataframe['rsi'] > self.enter_short_rsi.value) & - (dataframe['fastd'] > 65) & - (dataframe['adx'] < 70) & - (dataframe['plus_di'] < self.enter_short_plusdi.value) - ) | - ( - (dataframe['adx'] < 35) & - (dataframe['plus_di'] < self.enter_short_plusdi.value) - ), - 'enter_short'] = 1 - return dataframe def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: @@ -211,20 +183,4 @@ class HyperoptableStrategy(IStrategy): (dataframe['minus_di'] > self.sell_minusdi.value) ), 'sell'] = 1 - - dataframe.loc[ - ( - ( - (qtpylib.crossed_below(dataframe['rsi'], self.exit_short_rsi.value)) | - (qtpylib.crossed_below(dataframe['fastd'], 30)) - ) & - (dataframe['adx'] < 90) & - (dataframe['minus_di'] < 0) # TODO-lev: What should this be - ) | - ( - (dataframe['adx'] < 30) & - (dataframe['minus_di'] < self.exit_short_minusdi.value) - ), - 'exit_short'] = 1 - return dataframe diff --git a/tests/strategy/strats/legacy_strategy.py b/tests/strategy/strats/legacy_strategy.py index 20f24d6a3..9ef00b110 100644 --- a/tests/strategy/strats/legacy_strategy.py +++ b/tests/strategy/strats/legacy_strategy.py @@ -84,5 +84,4 @@ class TestStrategyLegacy(IStrategy): (dataframe['volume'] > 0) ), 'sell'] = 1 - return dataframe diff --git a/tests/strategy/test_interface.py b/tests/strategy/test_interface.py index 958f4ebed..5aa18c7db 100644 --- a/tests/strategy/test_interface.py +++ b/tests/strategy/test_interface.py @@ -747,11 +747,10 @@ def test_auto_hyperopt_interface(default_conf): assert strategy.sell_minusdi.value == 0.5 all_params = strategy.detect_all_parameters() assert isinstance(all_params, dict) - # TODO-lev: Should these be 4,4 and 10? - assert len(all_params['buy']) == 4 - assert len(all_params['sell']) == 4 + assert len(all_params['buy']) == 2 + assert len(all_params['sell']) == 2 # Number of Hyperoptable parameters - assert all_params['count'] == 10 + assert all_params['count'] == 6 strategy.__class__.sell_rsi = IntParameter([0, 10], default=5, space='buy') diff --git a/tests/strategy/test_strategy_loading.py b/tests/strategy/test_strategy_loading.py index 73c7cb5f7..1c846ec13 100644 --- a/tests/strategy/test_strategy_loading.py +++ b/tests/strategy/test_strategy_loading.py @@ -119,11 +119,9 @@ def test_strategy(result, default_conf): dataframe = strategy.advise_buy(df_indicators, metadata=metadata) assert 'buy' in dataframe.columns - assert 'enter_short' in dataframe.columns dataframe = strategy.advise_sell(df_indicators, metadata=metadata) assert 'sell' in dataframe.columns - assert 'exit_short' in dataframe.columns def test_strategy_override_minimal_roi(caplog, default_conf): @@ -415,9 +413,7 @@ def test_strategy_interface_versioning(result, monkeypatch, default_conf): enterdf = strategy.advise_buy(result, metadata=metadata) assert isinstance(enterdf, DataFrame) assert 'buy' in enterdf.columns - assert 'enter_short' in enterdf.columns exitdf = strategy.advise_sell(result, metadata=metadata) assert isinstance(exitdf, DataFrame) assert 'sell' in exitdf - assert 'exit_short' in exitdf.columns