Use JSON Schema validation for freaAI schema validation

This commit is contained in:
Matthias 2022-07-31 15:23:27 +02:00
parent cbb05354a8
commit 659870312d
2 changed files with 13 additions and 33 deletions

View File

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

View File

@ -241,6 +241,7 @@ CONF_SCHEMA = {
}, },
'exchange': {'$ref': '#/definitions/exchange'}, 'exchange': {'$ref': '#/definitions/exchange'},
'edge': {'$ref': '#/definitions/edge'}, 'edge': {'$ref': '#/definitions/edge'},
'freqai': {'$ref': '#/definitions/freqai'},
'experimental': { 'experimental': {
'type': 'object', 'type': 'object',
'properties': { 'properties': {
@ -484,20 +485,21 @@ CONF_SCHEMA = {
"keras": {"type": "boolean", "default": False}, "keras": {"type": "boolean", "default": False},
"conv_width": {"type": "integer", "default": 2}, "conv_width": {"type": "integer", "default": 2},
"train_period_days": {"type": "integer", "default": 0}, "train_period_days": {"type": "integer", "default": 0},
"backtest_period_days": {"type": "float", "default": 7}, "backtest_period_days": {"type": "number", "default": 7},
"identifier": {"type": "str", "default": "example"}, "identifier": {"type": "string", "default": "example"},
"feature_parameters": { "feature_parameters": {
"type": "object", "type": "object",
"properties": { "properties": {
"include_corr_pairlist": {"type": "list"}, "include_corr_pairlist": {"type": "array"},
"include_timeframes": {"type": "list"}, "include_timeframes": {"type": "array"},
"label_period_candles": {"type": "integer"}, "label_period_candles": {"type": "integer"},
"include_shifted_candles": {"type": "integer", "default": 0}, "include_shifted_candles": {"type": "integer", "default": 0},
"DI_threshold": {"type": "float", "default": 0}, "DI_threshold": {"type": "number", "default": 0},
"weight_factor": {"type": "number", "default": 0}, "weight_factor": {"type": "number", "default": 0},
"principal_component_analysis": {"type": "boolean", "default": False}, "principal_component_analysis": {"type": "boolean", "default": False},
"use_SVM_to_remove_outliers": {"type": "boolean", "default": False}, "use_SVM_to_remove_outliers": {"type": "boolean", "default": False},
}, },
"required": ["include_timeframes", "include_corr_pairlist", ]
}, },
"data_split_parameters": { "data_split_parameters": {
"type": "object", "type": "object",
@ -516,6 +518,12 @@ CONF_SCHEMA = {
}, },
}, },
}, },
"required": ["train_period_days",
"backtest_period_days",
"identifier",
"feature_parameters",
"data_split_parameters",
"model_training_parameters"]
}, },
}, },
} }
@ -560,17 +568,6 @@ SCHEMA_MINIMAL_REQUIRED = [
'dataformat_trades', 'dataformat_trades',
] ]
SCHEMA_FREQAI_REQUIRED = [
'include_timeframes',
'train_period_days',
'backtest_period_days',
'identifier',
'include_corr_pairlist',
'feature_parameters',
'data_split_parameters',
'model_training_parameters'
]
CANCEL_REASON = { CANCEL_REASON = {
"TIMEOUT": "cancelled due to timeout", "TIMEOUT": "cancelled due to timeout",
"PARTIALLY_FILLED_KEEP_OPEN": "partially filled - keeping order open", "PARTIALLY_FILLED_KEEP_OPEN": "partially filled - keeping order open",