add tests for spice_rack

This commit is contained in:
robcaulk
2022-09-16 00:46:55 +02:00
parent b209490009
commit fb2d190865
5 changed files with 48 additions and 6 deletions

View File

@@ -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

View File

@@ -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