From 7ff32586075fdb4266ce53027e8f99054385388c Mon Sep 17 00:00:00 2001 From: robcaulk Date: Wed, 25 May 2022 11:43:45 +0200 Subject: [PATCH] remove assertions, log error if user has not assigned freqai in config, fix stratify bug --- config_examples/config_freqai.example.json | 1 - freqtrade/freqai/data_kitchen.py | 39 ++++++++++++---------- freqtrade/freqai/freqai_interface.py | 23 +++++++------ 3 files changed, 34 insertions(+), 29 deletions(-) diff --git a/config_examples/config_freqai.example.json b/config_examples/config_freqai.example.json index ed3782775..5f7f38373 100644 --- a/config_examples/config_freqai.example.json +++ b/config_examples/config_freqai.example.json @@ -62,7 +62,6 @@ "corr_pairlist": [ "BTC/USDT", "ETH/USDT", - "LINK/USDT", "DOT/USDT" ], "feature_parameters": { diff --git a/freqtrade/freqai/data_kitchen.py b/freqtrade/freqai/data_kitchen.py index 765c58a37..b0eb8b40d 100644 --- a/freqtrade/freqai/data_kitchen.py +++ b/freqtrade/freqai/data_kitchen.py @@ -73,23 +73,26 @@ class FreqaiDataKitchen: self.data_drawer = data_drawer def assert_config(self, config: Dict[str, Any], live: bool) -> None: - assert config.get('freqai'), "No Freqai parameters found in config file." - assert config.get('freqai', {}).get('train_period'), ("No Freqai train_period found in" - "config file.") - assert type(config.get('freqai', {}) - .get('train_period')) is int, ('Can only train on full day period.' - 'No fractional days permitted.') - assert config.get('freqai', {}).get('backtest_period'), ("No Freqai backtest_period found" - "in config file.") - if not live: - assert type(config.get('freqai', {}) - .get('backtest_period')) is int, ('Can only backtest on full day' - 'backtest_period. Only live/dry mode' - 'allows fractions of days') - assert config.get('freqai', {}).get('identifier'), ("No Freqai identifier found in config" - "file.") - assert config.get('freqai', {}).get('feature_parameters'), ("No Freqai feature_parameters" - "found in config file.") + if not config.get('freqai'): + logger.error('No Freqai parameters found in config file.') + + # assert config.get('freqai'), "No Freqai parameters found in config file." + # assert config.get('freqai', {}).get('train_period'), ("No Freqai train_period found in" + # "config file.") + # assert type(config.get('freqai', {}) + # .get('train_period')) is int, ('Can only train on full day period.' + # 'No fractional days permitted.') + # assert config.get('freqai', {}).get('backtest_period'), ("No Freqai backtest_period found" + # "in config file.") + # if not live: + # assert type(config.get('freqai', {}) + # .get('backtest_period')) is int, ('Can only backtest on full day' + # 'backtest_period. Only live/dry mode' + # 'allows fractions of days') + # assert config.get('freqai', {}).get('identifier'), ("No Freqai identifier found in config" + # "file.") + # assert config.get('freqai', {}).get('feature_parameters'), ("No Freqai feature_parameters" + # "found in config file.") def set_paths(self, metadata: dict, trained_timestamp: int = None,) -> None: self.full_path = Path(self.config['user_data_dir'] / @@ -234,6 +237,8 @@ class FreqaiDataKitchen: for i in range(1, len(stratification)): if i % self.freqai_config.get("feature_parameters", {}).get("stratify", 0) == 0: stratification[i] = 1 + else: + stratification = None ( train_features, diff --git a/freqtrade/freqai/freqai_interface.py b/freqtrade/freqai/freqai_interface.py index d60f37ffb..041343683 100644 --- a/freqtrade/freqai/freqai_interface.py +++ b/freqtrade/freqai/freqai_interface.py @@ -57,17 +57,18 @@ class IFreqaiModel(ABC): self.config['exchange']['pair_whitelist']) def assert_config(self, config: Dict[str, Any]) -> None: - - assert config.get('freqai'), "No Freqai parameters found in config file." - assert config.get('freqai', {}).get('data_split_parameters'), ("No Freqai" - "data_split_parameters" - "in config file.") - assert config.get('freqai', {}).get('model_training_parameters'), ("No Freqai" - "modeltrainingparameters" - "found in config file.") - assert config.get('freqai', {}).get('feature_parameters'), ("No Freqai" - "feature_parameters found in" - "config file.") + if not config.get('freqai'): + logger.error('No Freqai parameters found in config file.') + # assert config.get('freqai'), "No Freqai parameters found in config file." + # assert config.get('freqai', {}).get('data_split_parameters'), ("No Freqai" + # "data_split_parameters" + # "in config file.") + # assert config.get('freqai', {}).get('model_training_parameters'), ("No Freqai" + # "modeltrainingparameters" + # "found in config file.") + # assert config.get('freqai', {}).get('feature_parameters'), ("No Freqai" + # "feature_parameters found in" + # "config file.") def start(self, dataframe: DataFrame, metadata: dict, strategy: IStrategy) -> DataFrame: """