From 2241f2429042e394f989f028a25567992c9292bd Mon Sep 17 00:00:00 2001 From: Wagner Costa Date: Tue, 10 Jan 2023 09:10:30 -0300 Subject: [PATCH] moved deprecated warning to start function --- freqtrade/freqai/data_kitchen.py | 7 ------- freqtrade/freqai/freqai_interface.py | 27 ++++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/freqtrade/freqai/data_kitchen.py b/freqtrade/freqai/data_kitchen.py index 719504122..9fdc2c98e 100644 --- a/freqtrade/freqai/data_kitchen.py +++ b/freqtrade/freqai/data_kitchen.py @@ -1349,13 +1349,6 @@ class FreqaiDataKitchen: else: # the user is using the populate_any_indicators functions which is deprecated - logger.warning("DEPRECATION WARNING: " - "You are using the deprecated populate_any_indicators function. " - "This function will raise an error on March 1 2023. " - "Please update your strategy by using " - "the new feature_engineering functions. See \n" - "https://www.freqtrade.io/en/latest/freqai-feature-engineering/" - "for details.") df = self.use_strategy_to_populate_indicators_old_version( strategy, corr_dataframes, base_dataframes, pair, diff --git a/freqtrade/freqai/freqai_interface.py b/freqtrade/freqai/freqai_interface.py index c4e87176c..830970ba0 100644 --- a/freqtrade/freqai/freqai_interface.py +++ b/freqtrade/freqai/freqai_interface.py @@ -1,3 +1,4 @@ +import inspect import logging import threading import time @@ -106,6 +107,8 @@ class IFreqaiModel(ABC): self.max_system_threads = max(int(psutil.cpu_count() * 2 - 2), 1) self.can_short = True # overridden in start() with strategy.can_short + self.warned_deprecated_populate_any_indicators = False + record_params(config, self.full_path) def __getstate__(self): @@ -136,6 +139,9 @@ class IFreqaiModel(ABC): self.data_provider = strategy.dp self.can_short = strategy.can_short + # check if the strategy has deprecated populate_any_indicators function + self.check_deprecated_populate_any_indicators(strategy) + if self.live: self.inference_timer('start') self.dk = FreqaiDataKitchen(self.config, self.live, metadata["pair"]) @@ -373,7 +379,6 @@ class IFreqaiModel(ABC): :returns: dk: FreqaiDataKitchen = Data management/analysis tool associated to present pair only """ - # update follower if self.follow_mode: self.dd.update_follower_metadata() @@ -939,6 +944,26 @@ class IFreqaiModel(ABC): dk.return_dataframe, saved_dataframe, how='left', left_on='date', right_on="date_pred") return dk + def check_deprecated_populate_any_indicators(self, strategy: IStrategy): + """ + Check and warn if the deprecated populate_any_indicators function is used. + :param strategy: strategy object + """ + + if not self.warned_deprecated_populate_any_indicators: + self.warned_deprecated_populate_any_indicators = True + old_version = inspect.getsource(strategy.populate_any_indicators) != ( + inspect.getsource(IStrategy.populate_any_indicators)) + + if old_version: + logger.warning("DEPRECATION WARNING: " + "You are using the deprecated populate_any_indicators function. " + "This function will raise an error on March 1 2023. " + "Please update your strategy by using " + "the new feature_engineering functions. See \n" + "https://www.freqtrade.io/en/latest/freqai-feature-engineering/" + "for details.") + # Following methods which are overridden by user made prediction models. # See freqai/prediction_models/CatboostPredictionModel.py for an example.