add tests for spice_rack
This commit is contained in:
parent
b209490009
commit
fb2d190865
@ -586,7 +586,6 @@ class FreqaiDataDrawer:
|
||||
pairs = self.freqai_info["feature_parameters"].get(
|
||||
"include_corr_pairlist", []
|
||||
)
|
||||
|
||||
for tf in self.freqai_info["feature_parameters"].get("include_timeframes"):
|
||||
base_dataframes[tf] = dk.slice_dataframe(timerange, historic_data[pair][tf])
|
||||
if pairs:
|
||||
|
@ -4,7 +4,8 @@
|
||||
"enabled": true,
|
||||
"purge_old_models": true,
|
||||
"train_period_days": 4,
|
||||
"identifier": "uniqe-id",
|
||||
"backtest_period_days": 2,
|
||||
"identifier": "spicy-id",
|
||||
"feature_parameters": {
|
||||
"include_timeframes": [
|
||||
"3m",
|
||||
|
@ -161,9 +161,6 @@ class IStrategy(ABC, HyperStrategyMixin):
|
||||
from freqtrade.freqai.utils import auto_populate_any_indicators
|
||||
self.populate_any_indicators = types.MethodType( # type: ignore
|
||||
auto_populate_any_indicators, self)
|
||||
# funcType = type(IStrategy.populate_any_indicators)
|
||||
# self.populate_any_indicators = funcType(self.freqai.auto_populate_any_indicators,
|
||||
# self, self.populate_any_indicators)
|
||||
|
||||
self.freqai_info = self.config["freqai"]
|
||||
|
||||
@ -192,8 +189,9 @@ class IStrategy(ABC, HyperStrategyMixin):
|
||||
def setup_freqai_spice_rack(self, config: dict) -> Dict[str, Any]:
|
||||
import json
|
||||
from pathlib import Path
|
||||
auto_config = config.get('freqai_config', 'lightgbm_config.json')
|
||||
with open(Path('freqtrade') / 'freqai' / 'spice_rack'
|
||||
/ 'lightgbm_config.json') as json_file:
|
||||
/ auto_config) as json_file:
|
||||
freqai_config = json.load(json_file)
|
||||
config['freqai'] = freqai_config['freqai']
|
||||
config['freqai']['identifier'] = config['freqai_identifier']
|
||||
|
@ -161,3 +161,28 @@ def test_make_train_test_datasets(mocker, freqai_conf):
|
||||
assert data_dictionary
|
||||
assert len(data_dictionary) == 7
|
||||
assert len(data_dictionary['train_features'].index) == 1916
|
||||
|
||||
|
||||
@pytest.mark.parametrize('indicator', [
|
||||
'%-ADArsi-period_10_5m',
|
||||
'doesnt_exist',
|
||||
])
|
||||
def test_spice_extractor(mocker, freqai_conf, indicator, caplog):
|
||||
freqai, unfiltered_dataframe = make_unfiltered_dataframe(mocker, freqai_conf)
|
||||
freqai.dk.find_features(unfiltered_dataframe)
|
||||
|
||||
features_filtered, labels_filtered = freqai.dk.filter_features(
|
||||
unfiltered_dataframe,
|
||||
freqai.dk.training_features_list,
|
||||
freqai.dk.label_list,
|
||||
training_filter=True,
|
||||
)
|
||||
|
||||
vec = freqai.dk.spice_extractor(indicator, features_filtered)
|
||||
if 'doesnt_exist' in indicator:
|
||||
assert log_has_re(
|
||||
"User asked spice_rack for",
|
||||
caplog,
|
||||
)
|
||||
else:
|
||||
assert len(vec) == 2860
|
||||
|
@ -1,3 +1,4 @@
|
||||
import copy
|
||||
import platform
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
@ -314,3 +315,21 @@ def test_principal_component_analysis(mocker, freqai_conf):
|
||||
assert Path(freqai.dk.data_path / f"{freqai.dk.model_filename}_pca_object.pkl")
|
||||
|
||||
shutil.rmtree(Path(freqai.dk.full_path))
|
||||
|
||||
|
||||
def test_spice_rack(mocker, default_conf, tmpdir):
|
||||
default_conf.update({"freqai_spice_rack": "true"})
|
||||
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"])
|
||||
default_conf['exchange'].update({'pair_whitelist':
|
||||
['ADA/BTC', 'DASH/BTC', 'ETH/BTC', 'LTC/BTC']})
|
||||
default_conf["user_data_dir"] = Path(tmpdir)
|
||||
freqai_conf = copy.deepcopy(default_conf)
|
||||
|
||||
_ = get_patched_freqai_strategy(mocker, freqai_conf)
|
||||
|
||||
assert 'freqai' in freqai_conf
|
||||
|
Loading…
Reference in New Issue
Block a user