proper validation of freqai config parameters

This commit is contained in:
robcaulk 2022-05-25 12:37:25 +02:00
parent 7ff3258607
commit 7486d9d9e2
5 changed files with 34 additions and 37 deletions

View File

@ -85,6 +85,7 @@ def validate_config_consistency(conf: Dict[str, Any], preliminary: bool = False)
_validate_unlimited_amount(conf)
_validate_ask_orderbook(conf)
validate_migrated_strategy_settings(conf)
_validate_freqai(conf)
# validate configuration before returning
logger.info('Validating configuration ...')
@ -163,6 +164,21 @@ def _validate_edge(conf: Dict[str, Any]) -> None:
)
def _validate_freqai(conf: Dict[str, Any]) -> None:
"""
Freqai param validator
"""
if not conf.get('freqai', {}):
return
for param in constants.SCHEMA_FREQAI_REQUIRED:
if param not in conf.get('freqai', {}):
raise OperationalException(
f'{param} not found in Freqai config'
)
def _validate_whitelist(conf: Dict[str, Any]) -> None:
"""
Dynamic whitelist does not require pair_whitelist to be set - however StaticWhitelist does.

View File

@ -515,6 +515,17 @@ SCHEMA_MINIMAL_REQUIRED = [
'dataformat_trades',
]
SCHEMA_FREQAI_REQUIRED = [
'timeframes',
'train_period',
'backtest_period',
'identifier',
'corr_pairlist',
'feature_parameters',
'data_split_parameters',
'model_training_parameters'
]
CANCEL_REASON = {
"TIMEOUT": "cancelled due to timeout",
"PARTIALLY_FILLED_KEEP_OPEN": "partially filled - keeping order open",

View File

@ -15,10 +15,9 @@ class RunMode(Enum):
UTIL_NO_EXCHANGE = "util_no_exchange"
PLOT = "plot"
WEBSERVER = "webserver"
FREQAI = "freqai"
OTHER = "other"
TRADING_MODES = [RunMode.LIVE, RunMode.DRY_RUN]
OPTIMIZE_MODES = [RunMode.BACKTEST, RunMode.EDGE, RunMode.HYPEROPT, RunMode.FREQAI]
OPTIMIZE_MODES = [RunMode.BACKTEST, RunMode.EDGE, RunMode.HYPEROPT]
NON_UTIL_MODES = TRADING_MODES + OPTIMIZE_MODES

View File

@ -44,7 +44,6 @@ class FreqaiDataKitchen:
self.data: Dict[Any, Any] = {}
self.data_dictionary: Dict[Any, Any] = {}
self.config = config
self.assert_config(self.config, live)
self.freqai_config = config["freqai"]
self.predictions: npt.ArrayLike = np.array([])
self.do_predict: npt.ArrayLike = np.array([])
@ -72,28 +71,6 @@ class FreqaiDataKitchen:
self.data_drawer = data_drawer
def assert_config(self, config: Dict[str, Any], live: bool) -> None:
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'] /
"models" /

View File

@ -13,6 +13,7 @@ from pandas import DataFrame
from freqtrade.configuration import TimeRange
from freqtrade.enums import RunMode
from freqtrade.exceptions import OperationalException
from freqtrade.freqai.data_drawer import FreqaiDataDrawer
from freqtrade.freqai.data_kitchen import FreqaiDataKitchen
from freqtrade.strategy.interface import IStrategy
@ -57,18 +58,11 @@ class IFreqaiModel(ABC):
self.config['exchange']['pair_whitelist'])
def assert_config(self, config: Dict[str, Any]) -> None:
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.")
if not config.get('freqai', {}):
raise OperationalException(
"No freqai parameters found in configuration file."
)
def start(self, dataframe: DataFrame, metadata: dict, strategy: IStrategy) -> DataFrame:
"""