Add "freqai.enabled" flag to disable freqAI via config flag

aligns with how other optional modules work in freqtrade.
This commit is contained in:
Matthias 2022-08-13 09:24:04 +02:00
parent 49989012ab
commit 3b827ee60a
6 changed files with 16 additions and 10 deletions

View File

@ -52,6 +52,7 @@
}
],
"freqai": {
"enabled": true,
"startup_candles": 10000,
"purge_old_models": true,
"train_period_days": 15,

View File

@ -486,6 +486,7 @@ CONF_SCHEMA = {
"freqai": {
"type": "object",
"properties": {
"enabled": {"type": "boolean", "default": False},
"keras": {"type": "boolean", "default": False},
"conv_width": {"type": "integer", "default": 2},
"train_period_days": {"type": "integer", "default": 0},
@ -525,12 +526,15 @@ CONF_SCHEMA = {
},
},
},
"required": ["train_period_days",
"required": [
"enabled",
"train_period_days",
"backtest_period_days",
"identifier",
"feature_parameters",
"data_split_parameters",
"model_training_parameters"]
"model_training_parameters"
]
},
},
}

View File

@ -89,7 +89,7 @@ class Backtesting:
self.dataprovider = DataProvider(self.config, self.exchange)
if self.config.get('strategy_list'):
if self.config.get('freqai'):
if self.config.get('freqai', {}).get('enabled', False):
raise OperationalException(
"You can't use strategy_list and freqai at the same time.")
for strat in list(self.config['strategy_list']):
@ -210,7 +210,7 @@ class Backtesting:
"""
self.progress.init_step(BacktestState.DATALOAD, 1)
if self.config.get('freqai') is not None:
if self.config.get('freqai', {}).get('enabled', False):
startup_candles = int(self.config.get('freqai', {}).get('startup_candles', 0))
if not startup_candles:
raise OperationalException('FreqAI backtesting module requires user set '

View File

@ -44,7 +44,7 @@ def expand_pairlist(wildcardpl: List[str], available_pairs: List[str],
def dynamic_expand_pairlist(config: dict, markets: list) -> List[str]:
expanded_pairs = expand_pairlist(config['pairs'], markets)
if config.get('freqai', {}):
if config.get('freqai', {}).get('enabled', False):
corr_pairlist = config['freqai']['feature_parameters']['include_corr_pairlist']
expanded_pairs += [pair for pair in corr_pairlist
if pair not in config['pairs']]

View File

@ -146,7 +146,7 @@ class IStrategy(ABC, HyperStrategyMixin):
self._ft_informative.append((informative_data, cls_method))
def load_freqAI_model(self) -> None:
if self.config.get('freqai', None):
if self.config.get('freqai', {}).get('enabled', False):
# Import here to avoid importing this if freqAI is disabled
from freqtrade.resolvers.freqaimodel_resolver import FreqaiModelResolver

View File

@ -17,6 +17,7 @@ def freqai_conf(default_conf, tmpdir):
freqaiconf = deepcopy(default_conf)
freqaiconf.update(
{
"enabled": True,
"datadir": Path(default_conf["datadir"]),
"strategy": "freqai_test_strat",
"user_data_dir": Path(tmpdir),