chore: move some setting-validations to config-schema

This commit is contained in:
Matthias
2025-10-30 06:33:04 +01:00
parent 2466cf85a1
commit f72e708627
3 changed files with 90 additions and 15 deletions

View File

@@ -5,7 +5,7 @@ Definition of cli arguments used in arguments.py
from argparse import ArgumentTypeError
from freqtrade import constants
from freqtrade.constants import HYPEROPT_LOSS_BUILTIN
from freqtrade.constants import HYPEROPT_BUILTIN_SPACES, HYPEROPT_LOSS_BUILTIN
from freqtrade.enums import CandleType
@@ -278,26 +278,15 @@ AVAILABLE_CLI_OPTIONS = {
),
"spaces": Arg(
"--spaces",
help="Specify which parameters to hyperopt. Space-separated list.",
choices=[
"all",
"buy",
"sell",
"roi",
"stoploss",
"trailing",
"protection",
"trades",
"default",
],
help="Specify which parameters to hyperopt. Space-separated list. Available options: "
f"{', '.join(HYPEROPT_BUILTIN_SPACES)}. Default: `default` - "
"which includes all spaces except for 'trailing', 'protection', and 'trades'.",
nargs="+",
default="default",
),
"analyze_per_epoch": Arg(
"--analyze-per-epoch",
help="Run populate_indicators once per epoch.",
action="store_true",
default=False,
),
"print_all": Arg(
"--print-all",

View File

@@ -1,11 +1,15 @@
# Required json-schema for user specified config
from freqtrade.constants import (
AVAILABLE_DATAHANDLERS,
AVAILABLE_PAIRLISTS,
BACKTEST_BREAKDOWNS,
BACKTEST_CACHE_AGE,
DRY_RUN_WALLET,
EXPORT_OPTIONS,
HYPEROPT_BUILTIN_SPACES,
HYPEROPT_LOSS_BUILTIN,
MARGIN_MODES,
ORDERTIF_POSSIBILITIES,
ORDERTYPE_POSSIBILITIES,
@@ -228,6 +232,76 @@ CONF_SCHEMA = {
"type": "array",
"items": {"type": "string", "enum": BACKTEST_BREAKDOWNS},
},
"backtest_cache": {
"description": "Load a cached backtest result no older than specified age.",
"type": "string",
"enum": BACKTEST_CACHE_AGE,
},
# Hyperopt
"hyperopt_path": {
"description": "Specify additional lookup path for Hyperopt Loss functions.",
"type": "string",
},
"epochs": {
"description": "Number of training epochs for Hyperopt.",
"type": "integer",
"minimum": 1,
},
"early_stop": {
"description": (
"Early stop hyperopt if no improvement after <epochs>. Set to 0 to disable."
),
"type": "integer",
"minimum": 0,
},
"spaces": {
"description": (
"Hyperopt parameter spaces to optimize. Default is the default set and"
"includes all spaces except for 'trailing', 'protection', and 'trades'."
),
"type": "array",
"items": {"type": "string", "enum": HYPEROPT_BUILTIN_SPACES},
"default": ["default"],
},
"analyze_per_epoch": {
"description": "Perform analysis after each epoch in Hyperopt.",
"type": "boolean",
},
"print_all": {
"description": "Print all hyperopt trials, not just the best ones.",
"type": "boolean",
"default": False,
},
"hyperopt_jobs": {
"description": (
"The number of concurrently running jobs for hyperoptimization "
"(hyperopt worker processes). "
"If -1 (default), all CPUs are used, for -2, all CPUs but one are used, etc. "
"If 1 is given, no parallel computing is used."
),
"type": "integer",
"default": -1,
},
"hyperopt_random_state": {
"description": "Random state for hyperopt trials.",
"type": "integer",
"minimum": 0,
},
"hyperopt_min_trades": {
"description": "Minimum number of trades per epoch for hyperopt.",
"type": "integer",
"minimum": 0,
},
"hyperopt_loss": {
"description": (
"The class name of the hyperopt loss function class (IHyperOptLoss). "
"Different functions can generate completely different results, "
"since the target for optimization is different. Built-in Hyperopt-loss-functions are: "
f"{', '.join(HYPEROPT_LOSS_BUILTIN)}"
),
"type": "string",
},
# end hyperopt
"bot_name": {
"description": "Name of the trading bot. Passed via API to a client.",
"type": "string",

View File

@@ -41,6 +41,18 @@ HYPEROPT_LOSS_BUILTIN = [
"ProfitDrawDownHyperOptLoss",
"MultiMetricHyperOptLoss",
]
HYPEROPT_BUILTIN_SPACES = [
"all",
"buy",
"sell",
"roi",
"stoploss",
"trailing",
"protection",
"trades",
"default",
]
AVAILABLE_PAIRLISTS = [
"StaticPairList",
"VolumePairList",