Improve error when hyperopt-loss-function is missing
This commit is contained in:
parent
28d6c3419b
commit
5cb3735a57
@ -4,6 +4,7 @@ Definition of cli arguments used in arguments.py
|
|||||||
from argparse import ArgumentTypeError
|
from argparse import ArgumentTypeError
|
||||||
|
|
||||||
from freqtrade import __version__, constants
|
from freqtrade import __version__, constants
|
||||||
|
from freqtrade.constants import HYPEROPT_LOSS_BUILTIN
|
||||||
|
|
||||||
|
|
||||||
def check_int_positive(value: str) -> int:
|
def check_int_positive(value: str) -> int:
|
||||||
@ -257,8 +258,7 @@ AVAILABLE_CLI_OPTIONS = {
|
|||||||
help='Specify the class name of the hyperopt loss function class (IHyperOptLoss). '
|
help='Specify the class name of the hyperopt loss function class (IHyperOptLoss). '
|
||||||
'Different functions can generate completely different results, '
|
'Different functions can generate completely different results, '
|
||||||
'since the target for optimization is different. Built-in Hyperopt-loss-functions are: '
|
'since the target for optimization is different. Built-in Hyperopt-loss-functions are: '
|
||||||
'ShortTradeDurHyperOptLoss, OnlyProfitHyperOptLoss, SharpeHyperOptLoss, '
|
f'{", ".join(HYPEROPT_LOSS_BUILTIN)}',
|
||||||
'SharpeHyperOptLossDaily, SortinoHyperOptLoss, SortinoHyperOptLossDaily.',
|
|
||||||
metavar='NAME',
|
metavar='NAME',
|
||||||
),
|
),
|
||||||
"hyperoptexportfilename": Arg(
|
"hyperoptexportfilename": Arg(
|
||||||
|
@ -20,6 +20,9 @@ REQUIRED_ORDERTYPES = ['buy', 'sell', 'stoploss', 'stoploss_on_exchange']
|
|||||||
ORDERBOOK_SIDES = ['ask', 'bid']
|
ORDERBOOK_SIDES = ['ask', 'bid']
|
||||||
ORDERTYPE_POSSIBILITIES = ['limit', 'market']
|
ORDERTYPE_POSSIBILITIES = ['limit', 'market']
|
||||||
ORDERTIF_POSSIBILITIES = ['gtc', 'fok', 'ioc']
|
ORDERTIF_POSSIBILITIES = ['gtc', 'fok', 'ioc']
|
||||||
|
HYPEROPT_LOSS_BUILTIN = ['ShortTradeDurHyperOptLoss', 'OnlyProfitHyperOptLoss',
|
||||||
|
'SharpeHyperOptLoss', 'SharpeHyperOptLossDaily',
|
||||||
|
'SortinoHyperOptLoss', 'SortinoHyperOptLossDaily']
|
||||||
AVAILABLE_PAIRLISTS = ['StaticPairList', 'VolumePairList',
|
AVAILABLE_PAIRLISTS = ['StaticPairList', 'VolumePairList',
|
||||||
'AgeFilter', 'PrecisionFilter', 'PriceFilter',
|
'AgeFilter', 'PrecisionFilter', 'PriceFilter',
|
||||||
'ShuffleFilter', 'SpreadFilter']
|
'ShuffleFilter', 'SpreadFilter']
|
||||||
|
@ -7,7 +7,7 @@ import logging
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
|
||||||
from freqtrade.constants import USERPATH_HYPEROPTS
|
from freqtrade.constants import HYPEROPT_LOSS_BUILTIN, USERPATH_HYPEROPTS
|
||||||
from freqtrade.exceptions import OperationalException
|
from freqtrade.exceptions import OperationalException
|
||||||
from freqtrade.optimize.hyperopt_interface import IHyperOpt
|
from freqtrade.optimize.hyperopt_interface import IHyperOpt
|
||||||
from freqtrade.optimize.hyperopt_loss_interface import IHyperOptLoss
|
from freqtrade.optimize.hyperopt_loss_interface import IHyperOptLoss
|
||||||
@ -72,8 +72,11 @@ class HyperOptLossResolver(IResolver):
|
|||||||
|
|
||||||
hyperoptloss_name = config.get('hyperopt_loss')
|
hyperoptloss_name = config.get('hyperopt_loss')
|
||||||
if not hyperoptloss_name:
|
if not hyperoptloss_name:
|
||||||
raise OperationalException("No Hyperopt loss set. Please use `--hyperopt-loss` to "
|
raise OperationalException(
|
||||||
"specify the Hyperopt-Loss class to use.")
|
"No Hyperopt loss set. Please use `--hyperopt-loss` to "
|
||||||
|
"specify the Hyperopt-Loss class to use.\n"
|
||||||
|
f"Built-in Hyperopt-loss-functions are: {', '.join(HYPEROPT_LOSS_BUILTIN)}"
|
||||||
|
)
|
||||||
hyperoptloss = HyperOptLossResolver.load_object(hyperoptloss_name,
|
hyperoptloss = HyperOptLossResolver.load_object(hyperoptloss_name,
|
||||||
config, kwargs={},
|
config, kwargs={},
|
||||||
extra_dir=config.get('hyperopt_path'))
|
extra_dir=config.get('hyperopt_path'))
|
||||||
|
Loading…
Reference in New Issue
Block a user