From 104f1212e6134973ff89b00f042552c389499bb4 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 25 May 2019 20:05:19 +0200 Subject: [PATCH] Move edge_cli_start to optimize --- freqtrade/arguments.py | 4 ++-- freqtrade/optimize/__init__.py | 16 ++++++++++++++++ freqtrade/optimize/edge_cli.py | 34 ---------------------------------- 3 files changed, 18 insertions(+), 36 deletions(-) diff --git a/freqtrade/arguments.py b/freqtrade/arguments.py index e79d0c6d4..d6f0063d0 100644 --- a/freqtrade/arguments.py +++ b/freqtrade/arguments.py @@ -340,7 +340,7 @@ class Arguments(object): Builds and attaches all subcommands :return: None """ - from freqtrade.optimize import start_backtesting, start_hyperopt, edge_cli + from freqtrade.optimize import start_backtesting, start_hyperopt, start_edgecli subparsers = self.parser.add_subparsers(dest='subparser') @@ -352,7 +352,7 @@ class Arguments(object): # Add edge subcommand edge_cmd = subparsers.add_parser('edge', help='Edge module.') - edge_cmd.set_defaults(func=edge_cli.start) + edge_cmd.set_defaults(func=start_edgecli) self.optimizer_shared_options(edge_cmd) self.edge_options(edge_cmd) diff --git a/freqtrade/optimize/__init__.py b/freqtrade/optimize/__init__.py index 34076ee43..cb01950b4 100644 --- a/freqtrade/optimize/__init__.py +++ b/freqtrade/optimize/__init__.py @@ -97,3 +97,19 @@ def start_hyperopt(args: Namespace) -> None: # TODO: return False here in order to help freqtrade to exit # with non-zero exit code... # Same in Edge and Backtesting start() functions. + + +def start_edgecli(args: Namespace) -> None: + """ + Start Edge script + :param args: Cli args from Arguments() + :return: None + """ + from freqtrade.optimize.edge_cli import EdgeCli + # Initialize configuration + config = setup_configuration(args, RunMode.EDGECLI) + logger.info('Starting freqtrade in Edge mode') + + # Initialize Edge object + edge_cli = EdgeCli(config) + edge_cli.start() diff --git a/freqtrade/optimize/edge_cli.py b/freqtrade/optimize/edge_cli.py index d37b930b8..8232c79c9 100644 --- a/freqtrade/optimize/edge_cli.py +++ b/freqtrade/optimize/edge_cli.py @@ -4,16 +4,13 @@ This module contains the edge backtesting interface """ import logging -from argparse import Namespace from typing import Dict, Any from tabulate import tabulate from freqtrade.edge import Edge from freqtrade.arguments import Arguments -from freqtrade.configuration import Configuration from freqtrade.exchange import Exchange from freqtrade.resolvers import StrategyResolver -from freqtrade.state import RunMode logger = logging.getLogger(__name__) @@ -77,34 +74,3 @@ class EdgeCli(object): if result: print('') # blank line for readability print(self._generate_edge_table(self.edge._cached_pairs)) - - -def setup_configuration(args: Namespace) -> Dict[str, Any]: - """ - Prepare the configuration for edge backtesting - :param args: Cli args from Arguments() - :return: Configuration - """ - configuration = Configuration(args, RunMode.EDGECLI) - config = configuration.get_config() - - # Ensure we do not use Exchange credentials - config['exchange']['key'] = '' - config['exchange']['secret'] = '' - - return config - - -def start(args: Namespace) -> None: - """ - Start Edge script - :param args: Cli args from Arguments() - :return: None - """ - # Initialize configuration - config = setup_configuration(args) - logger.info('Starting freqtrade in Edge mode') - - # Initialize Edge object - edge_cli = EdgeCli(config) - edge_cli.start()