From 04382d4b44c867034ff4c1dd21e49d432879baf3 Mon Sep 17 00:00:00 2001 From: hroff-1902 Date: Mon, 22 Jul 2019 19:37:34 +0300 Subject: [PATCH 1/2] add --hyperopt-path option --- docs/bot-usage.md | 5 ++++- freqtrade/configuration/arguments.py | 8 +++++++- freqtrade/configuration/configuration.py | 7 +++++-- freqtrade/resolvers/hyperopt_resolver.py | 4 ++-- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/docs/bot-usage.md b/docs/bot-usage.md index c643ecace..8031a2072 100644 --- a/docs/bot-usage.md +++ b/docs/bot-usage.md @@ -201,7 +201,8 @@ to find optimal parameter values for your stategy. usage: freqtrade hyperopt [-h] [-i TICKER_INTERVAL] [--timerange TIMERANGE] [--max_open_trades INT] [--stake_amount STAKE_AMOUNT] [-r] - [--customhyperopt NAME] [--eps] [-e INT] + [--customhyperopt NAME] [--hyperopt-path PATH] + [--eps] [-e INT] [-s {all,buy,sell,roi,stoploss} [{all,buy,sell,roi,stoploss} ...]] [--dmmp] [--print-all] [-j JOBS] [--random-state INT] [--min-trades INT] [--continue] @@ -225,6 +226,8 @@ optional arguments: --customhyperopt NAME Specify hyperopt class name (default: `DefaultHyperOpts`). + --hyperopt-path PATH Specify additional lookup path for Hyperopts and + Hyperopt Loss functions. --eps, --enable-position-stacking Allow buying the same pair multiple times (position stacking). diff --git a/freqtrade/configuration/arguments.py b/freqtrade/configuration/arguments.py index 3bbdc4bc2..c70d1b4d2 100644 --- a/freqtrade/configuration/arguments.py +++ b/freqtrade/configuration/arguments.py @@ -168,6 +168,11 @@ AVAILABLE_CLI_OPTIONS = { metavar='NAME', default=constants.DEFAULT_HYPEROPT, ), + "hyperopt_path": Arg( + '--hyperopt-path', + help='Specify additional lookup path for Hyperopts and Hyperopt Loss functions.', + metavar='PATH', + ), "epochs": Arg( '-e', '--epochs', help='Specify number of epochs (default: %(default)d).', @@ -312,7 +317,8 @@ ARGS_COMMON_OPTIMIZE = ["ticker_interval", "timerange", ARGS_BACKTEST = ARGS_COMMON_OPTIMIZE + ["position_stacking", "use_max_market_positions", "live", "strategy_list", "export", "exportfilename"] -ARGS_HYPEROPT = ARGS_COMMON_OPTIMIZE + ["hyperopt", "position_stacking", "epochs", "spaces", +ARGS_HYPEROPT = ARGS_COMMON_OPTIMIZE + ["hyperopt", "hyperopt_path", + "position_stacking", "epochs", "spaces", "use_max_market_positions", "print_all", "hyperopt_jobs", "hyperopt_random_state", "hyperopt_min_trades", "hyperopt_continue", "hyperopt_loss"] diff --git a/freqtrade/configuration/configuration.py b/freqtrade/configuration/configuration.py index 737eb0900..c97bd277a 100644 --- a/freqtrade/configuration/configuration.py +++ b/freqtrade/configuration/configuration.py @@ -129,8 +129,8 @@ class Configuration(object): if self.args.strategy != constants.DEFAULT_STRATEGY or not config.get('strategy'): config.update({'strategy': self.args.strategy}) - if self.args.strategy_path: - config.update({'strategy_path': self.args.strategy_path}) + self._args_to_config(config, argname='strategy_path', + logstring='Using additional Strategy lookup path: {}') def _process_common_options(self, config: Dict[str, Any]) -> None: @@ -239,6 +239,9 @@ class Configuration(object): self._args_to_config(config, argname='hyperopt', logstring='Using Hyperopt file {}') + self._args_to_config(config, argname='hyperopt_path', + logstring='Using additional Hyperopt lookup path: {}') + self._args_to_config(config, argname='epochs', logstring='Parameter --epochs detected ... ' 'Will run Hyperopt with for {} epochs ...' diff --git a/freqtrade/resolvers/hyperopt_resolver.py b/freqtrade/resolvers/hyperopt_resolver.py index 74412e738..5027d7ddf 100644 --- a/freqtrade/resolvers/hyperopt_resolver.py +++ b/freqtrade/resolvers/hyperopt_resolver.py @@ -60,7 +60,7 @@ class HyperOptResolver(IResolver): if extra_dir: # Add extra hyperopt directory on top of search paths - abs_paths.insert(0, Path(extra_dir)) + abs_paths.insert(0, Path(extra_dir).resolve()) hyperopt = self._load_object(paths=abs_paths, object_type=IHyperOpt, object_name=hyperopt_name) @@ -115,7 +115,7 @@ class HyperOptLossResolver(IResolver): if extra_dir: # Add extra hyperopt directory on top of search paths - abs_paths.insert(0, Path(extra_dir)) + abs_paths.insert(0, Path(extra_dir).resolve()) hyperoptloss = self._load_object(paths=abs_paths, object_type=IHyperOptLoss, object_name=hyper_loss_name) From 05be16e9e1dee7510bcf5ba1d5d9eadb53cca2a2 Mon Sep 17 00:00:00 2001 From: hroff-1902 Date: Thu, 25 Jul 2019 08:49:33 +0300 Subject: [PATCH 2/2] helpstring alignment fixed --- docs/bot-usage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/bot-usage.md b/docs/bot-usage.md index 8031a2072..4462b63c6 100644 --- a/docs/bot-usage.md +++ b/docs/bot-usage.md @@ -201,7 +201,7 @@ to find optimal parameter values for your stategy. usage: freqtrade hyperopt [-h] [-i TICKER_INTERVAL] [--timerange TIMERANGE] [--max_open_trades INT] [--stake_amount STAKE_AMOUNT] [-r] - [--customhyperopt NAME] [--hyperopt-path PATH] + [--customhyperopt NAME] [--hyperopt-path PATH] [--eps] [-e INT] [-s {all,buy,sell,roi,stoploss} [{all,buy,sell,roi,stoploss} ...]] [--dmmp] [--print-all] [-j JOBS]