improve spice rack test, remove spice rack test strat
This commit is contained in:
parent
b1e92933f4
commit
793c54db9d
@ -319,16 +319,15 @@ def test_principal_component_analysis(mocker, freqai_conf):
|
||||
shutil.rmtree(Path(freqai.dk.full_path))
|
||||
|
||||
|
||||
def test_spice_rack(mocker, default_conf, tmpdir):
|
||||
def test_spice_rack(mocker, default_conf, tmpdir, caplog):
|
||||
|
||||
strategy = get_patched_freqai_strategy(mocker, default_conf)
|
||||
exchange = get_patched_exchange(mocker, default_conf)
|
||||
strategy.dp = DataProvider(default_conf, exchange)
|
||||
|
||||
default_conf.update({"freqai_spice_rack": "true"})
|
||||
default_conf.update({"freqai_config": "test_config.json"})
|
||||
# default_conf.update({"freqai_config": "test_config.json"})
|
||||
default_conf.update({"freqai_identifier": "spicy-id"})
|
||||
default_conf.update({"strategy": "freqai_test_spice_rack"})
|
||||
default_conf["config_files"] = [Path('config_examples', 'config_freqai.example.json')]
|
||||
default_conf["timerange"] = "20180110-20180115"
|
||||
default_conf["datadir"] = Path(default_conf["datadir"])
|
||||
@ -340,6 +339,8 @@ def test_spice_rack(mocker, default_conf, tmpdir):
|
||||
strategy.config = freqai_conf
|
||||
strategy.load_freqAI_model()
|
||||
|
||||
assert log_has_re("Spice rack will use LTC/USD", caplog)
|
||||
assert log_has_re("Spice rack will use 15m", caplog)
|
||||
assert 'freqai' in freqai_conf
|
||||
assert strategy.freqai
|
||||
|
||||
|
@ -1430,7 +1430,6 @@ def test_api_strategies(botclient):
|
||||
'StrategyTestV3Futures',
|
||||
'freqai_test_classifier',
|
||||
'freqai_test_multimodel_strat',
|
||||
'freqai_test_spice_rack',
|
||||
'freqai_test_strat'
|
||||
]}
|
||||
|
||||
|
@ -1,79 +0,0 @@
|
||||
import logging
|
||||
|
||||
import talib.abstract as ta
|
||||
from pandas import DataFrame
|
||||
|
||||
from freqtrade.strategy import IStrategy
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class freqai_test_spice_rack(IStrategy):
|
||||
"""
|
||||
Test strategy - used for testing freqAI functionalities.
|
||||
DO not use in production.
|
||||
"""
|
||||
|
||||
minimal_roi = {"0": 0.1, "240": -1}
|
||||
|
||||
process_only_new_candles = True
|
||||
startup_candle_count: int = 30
|
||||
|
||||
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
|
||||
# Example of how to use the freqai.spice_rack. User treats it the same as any
|
||||
# typical talib indicator. They set a new column in their dataframe
|
||||
|
||||
dataframe['dissimilarity_index'] = self.freqai.spice_rack(
|
||||
'DI_values', dataframe, metadata, self)
|
||||
dataframe['maxima'] = self.freqai.spice_rack(
|
||||
'&s-maxima', dataframe, metadata, self)
|
||||
dataframe['minima'] = self.freqai.spice_rack(
|
||||
'&s-minima', dataframe, metadata, self)
|
||||
self.freqai.close_spice_rack() # user must close the spicerack
|
||||
|
||||
dataframe['rsi'] = ta.RSI(dataframe)
|
||||
|
||||
return dataframe
|
||||
|
||||
def populate_entry_trend(self, df: DataFrame, metadata: dict) -> DataFrame:
|
||||
|
||||
df.loc[
|
||||
(
|
||||
(df['rsi'] > df['rsi'].shift(1)) & # Guard: tema is raising
|
||||
(df['dissimilarity_index'] < 1) &
|
||||
(df['maxima'] > 0.1)
|
||||
),
|
||||
'enter_long'] = 1
|
||||
|
||||
df.loc[
|
||||
(
|
||||
(df['rsi'] < df['rsi'].shift(1)) & # Guard: tema is falling
|
||||
(df['dissimilarity_index'] < 1) &
|
||||
(df['minima'] > 0.1)
|
||||
),
|
||||
'enter_short'] = 1
|
||||
|
||||
return df
|
||||
|
||||
def populate_exit_trend(self, df: DataFrame, metadata: dict) -> DataFrame:
|
||||
|
||||
df.loc[
|
||||
(
|
||||
(df['rsi'] < df['rsi'].shift(1)) & # Guard: tema is falling
|
||||
(df['dissimilarity_index'] < 1) &
|
||||
(df['maxima'] > 0.1)
|
||||
),
|
||||
|
||||
'exit_long'] = 1
|
||||
|
||||
df.loc[
|
||||
(
|
||||
(df['rsi'] > df['rsi'].shift(1)) & # Guard: tema is raising
|
||||
(df['dissimilarity_index'] < 1) &
|
||||
(df['minima'] > 0.1)
|
||||
),
|
||||
'exit_short'] = 1
|
||||
|
||||
return df
|
@ -34,7 +34,7 @@ def test_search_all_strategies_no_failed():
|
||||
directory = Path(__file__).parent / "strats"
|
||||
strategies = StrategyResolver.search_all_objects(directory, enum_failed=False)
|
||||
assert isinstance(strategies, list)
|
||||
assert len(strategies) == 10
|
||||
assert len(strategies) == 9
|
||||
assert isinstance(strategies[0], dict)
|
||||
|
||||
|
||||
@ -42,10 +42,10 @@ def test_search_all_strategies_with_failed():
|
||||
directory = Path(__file__).parent / "strats"
|
||||
strategies = StrategyResolver.search_all_objects(directory, enum_failed=True)
|
||||
assert isinstance(strategies, list)
|
||||
assert len(strategies) == 11
|
||||
assert len(strategies) == 10
|
||||
# with enum_failed=True search_all_objects() shall find 2 good strategies
|
||||
# and 1 which fails to load
|
||||
assert len([x for x in strategies if x['class'] is not None]) == 10
|
||||
assert len([x for x in strategies if x['class'] is not None]) == 9
|
||||
assert len([x for x in strategies if x['class'] is None]) == 1
|
||||
|
||||
directory = Path(__file__).parent / "strats_nonexistingdir"
|
||||
|
Loading…
Reference in New Issue
Block a user