2022-09-15 22:46:55 +00:00
|
|
|
import copy
|
2022-07-24 05:32:13 +00:00
|
|
|
import platform
|
2022-07-20 10:56:46 +00:00
|
|
|
import shutil
|
|
|
|
from pathlib import Path
|
|
|
|
from unittest.mock import MagicMock
|
|
|
|
|
2022-07-24 05:32:13 +00:00
|
|
|
import pytest
|
|
|
|
|
2022-07-20 10:56:46 +00:00
|
|
|
from freqtrade.configuration import TimeRange
|
|
|
|
from freqtrade.data.dataprovider import DataProvider
|
|
|
|
from freqtrade.freqai.data_kitchen import FreqaiDataKitchen
|
2022-07-20 14:14:19 +00:00
|
|
|
from tests.conftest import get_patched_exchange, log_has_re
|
2022-07-24 05:32:13 +00:00
|
|
|
from tests.freqai.conftest import get_patched_freqai_strategy
|
2022-07-20 10:56:46 +00:00
|
|
|
|
|
|
|
|
2022-08-08 18:15:18 +00:00
|
|
|
def is_arm() -> bool:
|
|
|
|
machine = platform.machine()
|
|
|
|
return "arm" in machine or "aarch64" in machine
|
|
|
|
|
2022-08-08 18:34:11 +00:00
|
|
|
|
2022-09-10 18:06:52 +00:00
|
|
|
@pytest.mark.parametrize('model', [
|
|
|
|
'LightGBMRegressor',
|
|
|
|
'XGBoostRegressor',
|
|
|
|
'CatboostRegressor',
|
|
|
|
])
|
|
|
|
def test_extract_data_and_train_model_Regressors(mocker, freqai_conf, model):
|
|
|
|
if is_arm() and model == 'CatboostRegressor':
|
|
|
|
pytest.skip("CatBoost is not supported on ARM")
|
|
|
|
|
|
|
|
freqai_conf.update({"freqaimodel": model})
|
2022-07-24 05:32:13 +00:00
|
|
|
freqai_conf.update({"timerange": "20180110-20180130"})
|
2022-09-10 18:06:52 +00:00
|
|
|
freqai_conf.update({"strategy": "freqai_test_strat"})
|
2022-07-20 10:56:46 +00:00
|
|
|
|
2022-07-24 05:32:13 +00:00
|
|
|
strategy = get_patched_freqai_strategy(mocker, freqai_conf)
|
|
|
|
exchange = get_patched_exchange(mocker, freqai_conf)
|
|
|
|
strategy.dp = DataProvider(freqai_conf, exchange)
|
|
|
|
strategy.freqai_info = freqai_conf.get("freqai", {})
|
2022-07-23 14:05:25 +00:00
|
|
|
freqai = strategy.freqai
|
2022-07-20 10:56:46 +00:00
|
|
|
freqai.live = True
|
2022-07-26 08:24:14 +00:00
|
|
|
freqai.dk = FreqaiDataKitchen(freqai_conf)
|
2022-07-20 10:56:46 +00:00
|
|
|
timerange = TimeRange.parse_timerange("20180110-20180130")
|
2022-07-26 08:24:14 +00:00
|
|
|
freqai.dd.load_all_pair_histories(timerange, freqai.dk)
|
2022-07-20 10:56:46 +00:00
|
|
|
|
|
|
|
freqai.dd.pair_dict = MagicMock()
|
|
|
|
|
|
|
|
data_load_timerange = TimeRange.parse_timerange("20180110-20180130")
|
|
|
|
new_timerange = TimeRange.parse_timerange("20180120-20180130")
|
|
|
|
|
2022-09-03 13:52:29 +00:00
|
|
|
freqai.extract_data_and_train_model(
|
|
|
|
new_timerange, "ADA/BTC", strategy, freqai.dk, data_load_timerange)
|
2022-07-20 10:56:46 +00:00
|
|
|
|
2022-07-25 08:48:04 +00:00
|
|
|
assert Path(freqai.dk.data_path / f"{freqai.dk.model_filename}_model.joblib").is_file()
|
|
|
|
assert Path(freqai.dk.data_path / f"{freqai.dk.model_filename}_metadata.json").is_file()
|
|
|
|
assert Path(freqai.dk.data_path / f"{freqai.dk.model_filename}_trained_df.pkl").is_file()
|
|
|
|
assert Path(freqai.dk.data_path / f"{freqai.dk.model_filename}_svm_model.joblib").is_file()
|
2022-07-20 10:56:46 +00:00
|
|
|
|
|
|
|
shutil.rmtree(Path(freqai.dk.full_path))
|
|
|
|
|
|
|
|
|
2022-09-10 17:57:21 +00:00
|
|
|
@pytest.mark.parametrize('model', [
|
|
|
|
'LightGBMRegressorMultiTarget',
|
|
|
|
'XGBoostRegressorMultiTarget',
|
|
|
|
'CatboostRegressorMultiTarget',
|
|
|
|
])
|
|
|
|
def test_extract_data_and_train_model_MultiTargets(mocker, freqai_conf, model):
|
|
|
|
if is_arm() and model == 'CatboostRegressorMultiTarget':
|
|
|
|
pytest.skip("CatBoost is not supported on ARM")
|
|
|
|
|
2022-07-26 08:24:14 +00:00
|
|
|
freqai_conf.update({"timerange": "20180110-20180130"})
|
|
|
|
freqai_conf.update({"strategy": "freqai_test_multimodel_strat"})
|
2022-09-10 17:57:21 +00:00
|
|
|
freqai_conf.update({"freqaimodel": model})
|
2022-07-26 08:24:14 +00:00
|
|
|
strategy = get_patched_freqai_strategy(mocker, freqai_conf)
|
|
|
|
exchange = get_patched_exchange(mocker, freqai_conf)
|
|
|
|
strategy.dp = DataProvider(freqai_conf, exchange)
|
|
|
|
strategy.freqai_info = freqai_conf.get("freqai", {})
|
|
|
|
freqai = strategy.freqai
|
|
|
|
freqai.live = True
|
|
|
|
freqai.dk = FreqaiDataKitchen(freqai_conf)
|
|
|
|
timerange = TimeRange.parse_timerange("20180110-20180130")
|
|
|
|
freqai.dd.load_all_pair_histories(timerange, freqai.dk)
|
|
|
|
|
|
|
|
freqai.dd.pair_dict = MagicMock()
|
|
|
|
|
|
|
|
data_load_timerange = TimeRange.parse_timerange("20180110-20180130")
|
|
|
|
new_timerange = TimeRange.parse_timerange("20180120-20180130")
|
|
|
|
|
2022-09-03 13:52:29 +00:00
|
|
|
freqai.extract_data_and_train_model(
|
|
|
|
new_timerange, "ADA/BTC", strategy, freqai.dk, data_load_timerange)
|
2022-07-26 08:24:14 +00:00
|
|
|
|
|
|
|
assert len(freqai.dk.label_list) == 2
|
|
|
|
assert Path(freqai.dk.data_path / f"{freqai.dk.model_filename}_model.joblib").is_file()
|
|
|
|
assert Path(freqai.dk.data_path / f"{freqai.dk.model_filename}_metadata.json").is_file()
|
|
|
|
assert Path(freqai.dk.data_path / f"{freqai.dk.model_filename}_trained_df.pkl").is_file()
|
|
|
|
assert Path(freqai.dk.data_path / f"{freqai.dk.model_filename}_svm_model.joblib").is_file()
|
2022-08-15 04:49:28 +00:00
|
|
|
assert len(freqai.dk.data['training_features_list']) == 26
|
2022-07-26 08:24:14 +00:00
|
|
|
|
|
|
|
shutil.rmtree(Path(freqai.dk.full_path))
|
|
|
|
|
|
|
|
|
2022-09-10 18:17:57 +00:00
|
|
|
@pytest.mark.parametrize('model', [
|
|
|
|
'LightGBMClassifier',
|
|
|
|
'CatboostClassifier',
|
|
|
|
])
|
|
|
|
def test_extract_data_and_train_model_Classifiers(mocker, freqai_conf, model):
|
|
|
|
if is_arm() and model == 'CatboostClassifier':
|
|
|
|
pytest.skip("CatBoost is not supported on ARM")
|
2022-08-06 15:51:21 +00:00
|
|
|
|
2022-09-10 18:17:57 +00:00
|
|
|
freqai_conf.update({"freqaimodel": model})
|
2022-08-06 15:51:21 +00:00
|
|
|
freqai_conf.update({"strategy": "freqai_test_classifier"})
|
2022-09-10 18:17:57 +00:00
|
|
|
freqai_conf.update({"timerange": "20180110-20180130"})
|
2022-08-06 15:51:21 +00:00
|
|
|
strategy = get_patched_freqai_strategy(mocker, freqai_conf)
|
|
|
|
exchange = get_patched_exchange(mocker, freqai_conf)
|
|
|
|
strategy.dp = DataProvider(freqai_conf, exchange)
|
|
|
|
|
|
|
|
strategy.freqai_info = freqai_conf.get("freqai", {})
|
|
|
|
freqai = strategy.freqai
|
|
|
|
freqai.live = True
|
|
|
|
freqai.dk = FreqaiDataKitchen(freqai_conf)
|
|
|
|
timerange = TimeRange.parse_timerange("20180110-20180130")
|
|
|
|
freqai.dd.load_all_pair_histories(timerange, freqai.dk)
|
|
|
|
|
|
|
|
freqai.dd.pair_dict = MagicMock()
|
|
|
|
|
|
|
|
data_load_timerange = TimeRange.parse_timerange("20180110-20180130")
|
2022-07-24 05:32:13 +00:00
|
|
|
new_timerange = TimeRange.parse_timerange("20180120-20180130")
|
|
|
|
|
2022-09-03 13:52:29 +00:00
|
|
|
freqai.extract_data_and_train_model(new_timerange, "ADA/BTC",
|
|
|
|
strategy, freqai.dk, data_load_timerange)
|
2022-07-24 05:32:13 +00:00
|
|
|
|
|
|
|
assert Path(freqai.dk.data_path / f"{freqai.dk.model_filename}_model.joblib").exists()
|
|
|
|
assert Path(freqai.dk.data_path / f"{freqai.dk.model_filename}_metadata.json").exists()
|
|
|
|
assert Path(freqai.dk.data_path / f"{freqai.dk.model_filename}_trained_df.pkl").exists()
|
|
|
|
assert Path(freqai.dk.data_path / f"{freqai.dk.model_filename}_svm_model.joblib").exists()
|
|
|
|
|
|
|
|
shutil.rmtree(Path(freqai.dk.full_path))
|
|
|
|
|
|
|
|
|
|
|
|
def test_start_backtesting(mocker, freqai_conf):
|
|
|
|
freqai_conf.update({"timerange": "20180120-20180130"})
|
2022-09-03 12:00:01 +00:00
|
|
|
freqai_conf.get("freqai", {}).update({"save_backtest_models": True})
|
2022-07-24 05:32:13 +00:00
|
|
|
strategy = get_patched_freqai_strategy(mocker, freqai_conf)
|
|
|
|
exchange = get_patched_exchange(mocker, freqai_conf)
|
|
|
|
strategy.dp = DataProvider(freqai_conf, exchange)
|
|
|
|
strategy.freqai_info = freqai_conf.get("freqai", {})
|
2022-07-23 14:05:25 +00:00
|
|
|
freqai = strategy.freqai
|
2022-07-20 10:56:46 +00:00
|
|
|
freqai.live = False
|
2022-07-26 08:24:14 +00:00
|
|
|
freqai.dk = FreqaiDataKitchen(freqai_conf)
|
2022-07-20 10:56:46 +00:00
|
|
|
timerange = TimeRange.parse_timerange("20180110-20180130")
|
2022-07-26 08:24:14 +00:00
|
|
|
freqai.dd.load_all_pair_histories(timerange, freqai.dk)
|
2022-07-20 10:56:46 +00:00
|
|
|
sub_timerange = TimeRange.parse_timerange("20180110-20180130")
|
2022-07-26 08:24:14 +00:00
|
|
|
corr_df, base_df = freqai.dd.get_base_and_corr_dataframes(sub_timerange, "LTC/BTC", freqai.dk)
|
2022-07-20 10:56:46 +00:00
|
|
|
|
|
|
|
df = freqai.dk.use_strategy_to_populate_indicators(strategy, corr_df, base_df, "LTC/BTC")
|
|
|
|
|
2022-07-25 13:07:09 +00:00
|
|
|
metadata = {"pair": "LTC/BTC"}
|
2022-07-20 10:56:46 +00:00
|
|
|
freqai.start_backtesting(df, metadata, freqai.dk)
|
|
|
|
model_folders = [x for x in freqai.dd.full_path.iterdir() if x.is_dir()]
|
|
|
|
|
2022-08-31 18:36:29 +00:00
|
|
|
assert len(model_folders) == 6
|
2022-07-20 10:56:46 +00:00
|
|
|
|
|
|
|
shutil.rmtree(Path(freqai.dk.full_path))
|
|
|
|
|
|
|
|
|
2022-07-25 13:07:09 +00:00
|
|
|
def test_start_backtesting_subdaily_backtest_period(mocker, freqai_conf):
|
|
|
|
freqai_conf.update({"timerange": "20180120-20180124"})
|
|
|
|
freqai_conf.get("freqai", {}).update({"backtest_period_days": 0.5})
|
2022-09-03 12:00:01 +00:00
|
|
|
freqai_conf.get("freqai", {}).update({"save_backtest_models": True})
|
2022-07-25 13:07:09 +00:00
|
|
|
strategy = get_patched_freqai_strategy(mocker, freqai_conf)
|
|
|
|
exchange = get_patched_exchange(mocker, freqai_conf)
|
|
|
|
strategy.dp = DataProvider(freqai_conf, exchange)
|
|
|
|
strategy.freqai_info = freqai_conf.get("freqai", {})
|
|
|
|
freqai = strategy.freqai
|
|
|
|
freqai.live = False
|
2022-07-26 08:24:14 +00:00
|
|
|
freqai.dk = FreqaiDataKitchen(freqai_conf)
|
2022-07-25 13:07:09 +00:00
|
|
|
timerange = TimeRange.parse_timerange("20180110-20180130")
|
2022-07-26 08:24:14 +00:00
|
|
|
freqai.dd.load_all_pair_histories(timerange, freqai.dk)
|
2022-07-25 13:07:09 +00:00
|
|
|
sub_timerange = TimeRange.parse_timerange("20180110-20180130")
|
2022-07-26 08:24:14 +00:00
|
|
|
corr_df, base_df = freqai.dd.get_base_and_corr_dataframes(sub_timerange, "LTC/BTC", freqai.dk)
|
2022-07-25 13:07:09 +00:00
|
|
|
|
|
|
|
df = freqai.dk.use_strategy_to_populate_indicators(strategy, corr_df, base_df, "LTC/BTC")
|
|
|
|
|
|
|
|
metadata = {"pair": "LTC/BTC"}
|
|
|
|
freqai.start_backtesting(df, metadata, freqai.dk)
|
|
|
|
model_folders = [x for x in freqai.dd.full_path.iterdir() if x.is_dir()]
|
2022-08-31 18:36:29 +00:00
|
|
|
assert len(model_folders) == 9
|
2022-07-25 13:07:09 +00:00
|
|
|
|
|
|
|
shutil.rmtree(Path(freqai.dk.full_path))
|
|
|
|
|
|
|
|
|
2022-07-24 05:32:13 +00:00
|
|
|
def test_start_backtesting_from_existing_folder(mocker, freqai_conf, caplog):
|
|
|
|
freqai_conf.update({"timerange": "20180120-20180130"})
|
2022-09-03 12:00:01 +00:00
|
|
|
freqai_conf.get("freqai", {}).update({"save_backtest_models": True})
|
2022-07-24 05:32:13 +00:00
|
|
|
strategy = get_patched_freqai_strategy(mocker, freqai_conf)
|
|
|
|
exchange = get_patched_exchange(mocker, freqai_conf)
|
|
|
|
strategy.dp = DataProvider(freqai_conf, exchange)
|
|
|
|
strategy.freqai_info = freqai_conf.get("freqai", {})
|
2022-07-23 14:05:25 +00:00
|
|
|
freqai = strategy.freqai
|
2022-07-20 10:56:46 +00:00
|
|
|
freqai.live = False
|
2022-07-26 08:24:14 +00:00
|
|
|
freqai.dk = FreqaiDataKitchen(freqai_conf)
|
2022-07-20 10:56:46 +00:00
|
|
|
timerange = TimeRange.parse_timerange("20180110-20180130")
|
2022-07-26 08:24:14 +00:00
|
|
|
freqai.dd.load_all_pair_histories(timerange, freqai.dk)
|
2022-07-20 10:56:46 +00:00
|
|
|
sub_timerange = TimeRange.parse_timerange("20180110-20180130")
|
2022-07-26 08:24:14 +00:00
|
|
|
corr_df, base_df = freqai.dd.get_base_and_corr_dataframes(sub_timerange, "LTC/BTC", freqai.dk)
|
2022-07-20 10:56:46 +00:00
|
|
|
|
|
|
|
df = freqai.dk.use_strategy_to_populate_indicators(strategy, corr_df, base_df, "LTC/BTC")
|
|
|
|
|
|
|
|
metadata = {"pair": "ADA/BTC"}
|
|
|
|
freqai.start_backtesting(df, metadata, freqai.dk)
|
|
|
|
model_folders = [x for x in freqai.dd.full_path.iterdir() if x.is_dir()]
|
|
|
|
|
2022-08-31 18:36:29 +00:00
|
|
|
assert len(model_folders) == 6
|
2022-07-20 10:56:46 +00:00
|
|
|
|
|
|
|
# without deleting the exiting folder structure, re-run
|
|
|
|
|
2022-07-24 05:32:13 +00:00
|
|
|
freqai_conf.update({"timerange": "20180120-20180130"})
|
|
|
|
strategy = get_patched_freqai_strategy(mocker, freqai_conf)
|
|
|
|
exchange = get_patched_exchange(mocker, freqai_conf)
|
|
|
|
strategy.dp = DataProvider(freqai_conf, exchange)
|
|
|
|
strategy.freqai_info = freqai_conf.get("freqai", {})
|
2022-07-23 14:05:25 +00:00
|
|
|
freqai = strategy.freqai
|
2022-07-20 10:56:46 +00:00
|
|
|
freqai.live = False
|
2022-07-26 08:24:14 +00:00
|
|
|
freqai.dk = FreqaiDataKitchen(freqai_conf)
|
2022-07-20 10:56:46 +00:00
|
|
|
timerange = TimeRange.parse_timerange("20180110-20180130")
|
2022-07-26 08:24:14 +00:00
|
|
|
freqai.dd.load_all_pair_histories(timerange, freqai.dk)
|
2022-07-20 10:56:46 +00:00
|
|
|
sub_timerange = TimeRange.parse_timerange("20180110-20180130")
|
2022-07-26 08:24:14 +00:00
|
|
|
corr_df, base_df = freqai.dd.get_base_and_corr_dataframes(sub_timerange, "LTC/BTC", freqai.dk)
|
2022-07-20 10:56:46 +00:00
|
|
|
|
|
|
|
df = freqai.dk.use_strategy_to_populate_indicators(strategy, corr_df, base_df, "LTC/BTC")
|
|
|
|
freqai.start_backtesting(df, metadata, freqai.dk)
|
2022-07-20 14:14:19 +00:00
|
|
|
|
|
|
|
assert log_has_re(
|
2022-09-03 12:00:01 +00:00
|
|
|
"Found backtesting prediction file ",
|
2022-07-20 10:56:46 +00:00
|
|
|
caplog,
|
|
|
|
)
|
|
|
|
|
2022-09-03 12:00:01 +00:00
|
|
|
path = (freqai.dd.full_path / freqai.dk.backtest_predictions_folder)
|
|
|
|
prediction_files = [x for x in path.iterdir() if x.is_file()]
|
|
|
|
assert len(prediction_files) == 5
|
|
|
|
|
2022-07-20 10:56:46 +00:00
|
|
|
shutil.rmtree(Path(freqai.dk.full_path))
|
2022-07-25 08:48:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_follow_mode(mocker, freqai_conf):
|
|
|
|
freqai_conf.update({"timerange": "20180110-20180130"})
|
|
|
|
|
|
|
|
strategy = get_patched_freqai_strategy(mocker, freqai_conf)
|
|
|
|
exchange = get_patched_exchange(mocker, freqai_conf)
|
|
|
|
strategy.dp = DataProvider(freqai_conf, exchange)
|
|
|
|
strategy.freqai_info = freqai_conf.get("freqai", {})
|
|
|
|
freqai = strategy.freqai
|
|
|
|
freqai.live = True
|
2022-07-26 08:24:14 +00:00
|
|
|
freqai.dk = FreqaiDataKitchen(freqai_conf)
|
2022-07-25 08:48:04 +00:00
|
|
|
timerange = TimeRange.parse_timerange("20180110-20180130")
|
2022-07-26 08:24:14 +00:00
|
|
|
freqai.dd.load_all_pair_histories(timerange, freqai.dk)
|
2022-07-25 08:48:04 +00:00
|
|
|
|
|
|
|
metadata = {"pair": "ADA/BTC"}
|
|
|
|
freqai.dd.set_pair_dict_info(metadata)
|
|
|
|
|
|
|
|
data_load_timerange = TimeRange.parse_timerange("20180110-20180130")
|
|
|
|
new_timerange = TimeRange.parse_timerange("20180120-20180130")
|
|
|
|
|
2022-09-03 13:52:29 +00:00
|
|
|
freqai.extract_data_and_train_model(
|
|
|
|
new_timerange, "ADA/BTC", strategy, freqai.dk, data_load_timerange)
|
2022-07-25 08:48:04 +00:00
|
|
|
|
|
|
|
assert Path(freqai.dk.data_path / f"{freqai.dk.model_filename}_model.joblib").is_file()
|
|
|
|
assert Path(freqai.dk.data_path / f"{freqai.dk.model_filename}_metadata.json").is_file()
|
|
|
|
assert Path(freqai.dk.data_path / f"{freqai.dk.model_filename}_trained_df.pkl").is_file()
|
|
|
|
assert Path(freqai.dk.data_path / f"{freqai.dk.model_filename}_svm_model.joblib").is_file()
|
|
|
|
|
|
|
|
# start the follower and ask it to predict on existing files
|
|
|
|
|
|
|
|
freqai_conf.get("freqai", {}).update({"follow_mode": "true"})
|
|
|
|
|
|
|
|
strategy = get_patched_freqai_strategy(mocker, freqai_conf)
|
|
|
|
exchange = get_patched_exchange(mocker, freqai_conf)
|
|
|
|
strategy.dp = DataProvider(freqai_conf, exchange)
|
|
|
|
strategy.freqai_info = freqai_conf.get("freqai", {})
|
|
|
|
freqai = strategy.freqai
|
|
|
|
freqai.live = True
|
2022-07-26 08:24:14 +00:00
|
|
|
freqai.dk = FreqaiDataKitchen(freqai_conf, freqai.live)
|
2022-07-25 08:48:04 +00:00
|
|
|
timerange = TimeRange.parse_timerange("20180110-20180130")
|
2022-07-26 08:24:14 +00:00
|
|
|
freqai.dd.load_all_pair_histories(timerange, freqai.dk)
|
2022-07-25 08:48:04 +00:00
|
|
|
|
|
|
|
df = strategy.dp.get_pair_dataframe('ADA/BTC', '5m')
|
|
|
|
freqai.start_live(df, metadata, strategy, freqai.dk)
|
|
|
|
|
|
|
|
assert len(freqai.dk.return_dataframe.index) == 5702
|
|
|
|
|
|
|
|
shutil.rmtree(Path(freqai.dk.full_path))
|
2022-07-25 09:46:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_principal_component_analysis(mocker, freqai_conf):
|
|
|
|
freqai_conf.update({"timerange": "20180110-20180130"})
|
|
|
|
freqai_conf.get("freqai", {}).get("feature_parameters", {}).update(
|
|
|
|
{"princpial_component_analysis": "true"})
|
|
|
|
|
|
|
|
strategy = get_patched_freqai_strategy(mocker, freqai_conf)
|
|
|
|
exchange = get_patched_exchange(mocker, freqai_conf)
|
|
|
|
strategy.dp = DataProvider(freqai_conf, exchange)
|
|
|
|
strategy.freqai_info = freqai_conf.get("freqai", {})
|
|
|
|
freqai = strategy.freqai
|
|
|
|
freqai.live = True
|
2022-07-26 08:24:14 +00:00
|
|
|
freqai.dk = FreqaiDataKitchen(freqai_conf)
|
2022-07-25 09:46:59 +00:00
|
|
|
timerange = TimeRange.parse_timerange("20180110-20180130")
|
2022-07-26 08:24:14 +00:00
|
|
|
freqai.dd.load_all_pair_histories(timerange, freqai.dk)
|
2022-07-25 09:46:59 +00:00
|
|
|
|
|
|
|
freqai.dd.pair_dict = MagicMock()
|
|
|
|
|
|
|
|
data_load_timerange = TimeRange.parse_timerange("20180110-20180130")
|
|
|
|
new_timerange = TimeRange.parse_timerange("20180120-20180130")
|
|
|
|
|
2022-09-03 13:52:29 +00:00
|
|
|
freqai.extract_data_and_train_model(
|
|
|
|
new_timerange, "ADA/BTC", strategy, freqai.dk, data_load_timerange)
|
2022-07-25 09:46:59 +00:00
|
|
|
|
|
|
|
assert Path(freqai.dk.data_path / f"{freqai.dk.model_filename}_pca_object.pkl")
|
|
|
|
|
|
|
|
shutil.rmtree(Path(freqai.dk.full_path))
|
2022-09-15 22:46:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
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
|