Skip to content

Commit f72e708

Browse files
committed
chore: move some setting-validations to config-schema
1 parent 2466cf8 commit f72e708

File tree

3 files changed

+90
-15
lines changed

3 files changed

+90
-15
lines changed

freqtrade/commands/cli_options.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from argparse import ArgumentTypeError
66

77
from freqtrade import constants
8-
from freqtrade.constants import HYPEROPT_LOSS_BUILTIN
8+
from freqtrade.constants import HYPEROPT_BUILTIN_SPACES, HYPEROPT_LOSS_BUILTIN
99
from freqtrade.enums import CandleType
1010

1111

@@ -278,26 +278,15 @@ def __init__(self, *args, **kwargs):
278278
),
279279
"spaces": Arg(
280280
"--spaces",
281-
help="Specify which parameters to hyperopt. Space-separated list.",
282-
choices=[
283-
"all",
284-
"buy",
285-
"sell",
286-
"roi",
287-
"stoploss",
288-
"trailing",
289-
"protection",
290-
"trades",
291-
"default",
292-
],
281+
help="Specify which parameters to hyperopt. Space-separated list. Available options: "
282+
f"{', '.join(HYPEROPT_BUILTIN_SPACES)}. Default: `default` - "
283+
"which includes all spaces except for 'trailing', 'protection', and 'trades'.",
293284
nargs="+",
294-
default="default",
295285
),
296286
"analyze_per_epoch": Arg(
297287
"--analyze-per-epoch",
298288
help="Run populate_indicators once per epoch.",
299289
action="store_true",
300-
default=False,
301290
),
302291
"print_all": Arg(
303292
"--print-all",

freqtrade/config_schema/config_schema.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
# Required json-schema for user specified config
22

3+
34
from freqtrade.constants import (
45
AVAILABLE_DATAHANDLERS,
56
AVAILABLE_PAIRLISTS,
67
BACKTEST_BREAKDOWNS,
8+
BACKTEST_CACHE_AGE,
79
DRY_RUN_WALLET,
810
EXPORT_OPTIONS,
11+
HYPEROPT_BUILTIN_SPACES,
12+
HYPEROPT_LOSS_BUILTIN,
913
MARGIN_MODES,
1014
ORDERTIF_POSSIBILITIES,
1115
ORDERTYPE_POSSIBILITIES,
@@ -228,6 +232,76 @@
228232
"type": "array",
229233
"items": {"type": "string", "enum": BACKTEST_BREAKDOWNS},
230234
},
235+
"backtest_cache": {
236+
"description": "Load a cached backtest result no older than specified age.",
237+
"type": "string",
238+
"enum": BACKTEST_CACHE_AGE,
239+
},
240+
# Hyperopt
241+
"hyperopt_path": {
242+
"description": "Specify additional lookup path for Hyperopt Loss functions.",
243+
"type": "string",
244+
},
245+
"epochs": {
246+
"description": "Number of training epochs for Hyperopt.",
247+
"type": "integer",
248+
"minimum": 1,
249+
},
250+
"early_stop": {
251+
"description": (
252+
"Early stop hyperopt if no improvement after <epochs>. Set to 0 to disable."
253+
),
254+
"type": "integer",
255+
"minimum": 0,
256+
},
257+
"spaces": {
258+
"description": (
259+
"Hyperopt parameter spaces to optimize. Default is the default set and"
260+
"includes all spaces except for 'trailing', 'protection', and 'trades'."
261+
),
262+
"type": "array",
263+
"items": {"type": "string", "enum": HYPEROPT_BUILTIN_SPACES},
264+
"default": ["default"],
265+
},
266+
"analyze_per_epoch": {
267+
"description": "Perform analysis after each epoch in Hyperopt.",
268+
"type": "boolean",
269+
},
270+
"print_all": {
271+
"description": "Print all hyperopt trials, not just the best ones.",
272+
"type": "boolean",
273+
"default": False,
274+
},
275+
"hyperopt_jobs": {
276+
"description": (
277+
"The number of concurrently running jobs for hyperoptimization "
278+
"(hyperopt worker processes). "
279+
"If -1 (default), all CPUs are used, for -2, all CPUs but one are used, etc. "
280+
"If 1 is given, no parallel computing is used."
281+
),
282+
"type": "integer",
283+
"default": -1,
284+
},
285+
"hyperopt_random_state": {
286+
"description": "Random state for hyperopt trials.",
287+
"type": "integer",
288+
"minimum": 0,
289+
},
290+
"hyperopt_min_trades": {
291+
"description": "Minimum number of trades per epoch for hyperopt.",
292+
"type": "integer",
293+
"minimum": 0,
294+
},
295+
"hyperopt_loss": {
296+
"description": (
297+
"The class name of the hyperopt loss function class (IHyperOptLoss). "
298+
"Different functions can generate completely different results, "
299+
"since the target for optimization is different. Built-in Hyperopt-loss-functions are: "
300+
f"{', '.join(HYPEROPT_LOSS_BUILTIN)}"
301+
),
302+
"type": "string",
303+
},
304+
# end hyperopt
231305
"bot_name": {
232306
"description": "Name of the trading bot. Passed via API to a client.",
233307
"type": "string",

freqtrade/constants.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@
4141
"ProfitDrawDownHyperOptLoss",
4242
"MultiMetricHyperOptLoss",
4343
]
44+
HYPEROPT_BUILTIN_SPACES = [
45+
"all",
46+
"buy",
47+
"sell",
48+
"roi",
49+
"stoploss",
50+
"trailing",
51+
"protection",
52+
"trades",
53+
"default",
54+
]
55+
4456
AVAILABLE_PAIRLISTS = [
4557
"StaticPairList",
4658
"VolumePairList",

0 commit comments

Comments
 (0)