list-exchanges subcommand added
This commit is contained in:
parent
08105641d9
commit
9c64965808
@ -335,12 +335,25 @@ class Arguments(object):
|
|||||||
metavar='INT',
|
metavar='INT',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def list_exchanges_options(parser: argparse.ArgumentParser) -> None:
|
||||||
|
"""
|
||||||
|
Parses given arguments for the list-exchanges command.
|
||||||
|
"""
|
||||||
|
parser.add_argument(
|
||||||
|
'-1',
|
||||||
|
help='Print exchanges in one column',
|
||||||
|
action='store_true',
|
||||||
|
dest='print_one_column',
|
||||||
|
)
|
||||||
|
|
||||||
def _build_subcommands(self) -> None:
|
def _build_subcommands(self) -> None:
|
||||||
"""
|
"""
|
||||||
Builds and attaches all subcommands
|
Builds and attaches all subcommands
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
from freqtrade.optimize import start_backtesting, start_hyperopt, start_edge
|
from freqtrade.optimize import start_backtesting, start_hyperopt, start_edge
|
||||||
|
from freqtrade.utils import start_list_exchanges
|
||||||
|
|
||||||
subparsers = self.parser.add_subparsers(dest='subparser')
|
subparsers = self.parser.add_subparsers(dest='subparser')
|
||||||
|
|
||||||
@ -362,6 +375,11 @@ class Arguments(object):
|
|||||||
self.optimizer_shared_options(hyperopt_cmd)
|
self.optimizer_shared_options(hyperopt_cmd)
|
||||||
self.hyperopt_options(hyperopt_cmd)
|
self.hyperopt_options(hyperopt_cmd)
|
||||||
|
|
||||||
|
# Add list-exchanges subcommand
|
||||||
|
list_exchanges_cmd = subparsers.add_parser('list-exchanges', help='List known exchanges.')
|
||||||
|
list_exchanges_cmd.set_defaults(func=start_list_exchanges)
|
||||||
|
self.list_exchanges_options(list_exchanges_cmd)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def parse_timerange(text: Optional[str]) -> TimeRange:
|
def parse_timerange(text: Optional[str]) -> TimeRange:
|
||||||
"""
|
"""
|
||||||
|
44
freqtrade/utils.py
Normal file
44
freqtrade/utils.py
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
import logging
|
||||||
|
from argparse import Namespace
|
||||||
|
from typing import Any, Dict
|
||||||
|
|
||||||
|
from freqtrade.configuration import Configuration
|
||||||
|
from freqtrade.exchange import supported_exchanges
|
||||||
|
from freqtrade.state import RunMode
|
||||||
|
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
def setup_configuration(args: Namespace, method: RunMode) -> Dict[str, Any]:
|
||||||
|
"""
|
||||||
|
Prepare the configuration for the Hyperopt module
|
||||||
|
:param args: Cli args from Arguments()
|
||||||
|
:return: Configuration
|
||||||
|
"""
|
||||||
|
configuration = Configuration(args, method)
|
||||||
|
config = configuration.load_config()
|
||||||
|
|
||||||
|
# Ensure we do not use Exchange credentials
|
||||||
|
config['exchange']['key'] = ''
|
||||||
|
config['exchange']['secret'] = ''
|
||||||
|
|
||||||
|
return config
|
||||||
|
|
||||||
|
|
||||||
|
def start_list_exchanges(args: Namespace) -> None:
|
||||||
|
"""
|
||||||
|
Start listing known exchanges
|
||||||
|
:param args: Cli args from Arguments()
|
||||||
|
:return: None
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Initialize configuration
|
||||||
|
config = setup_configuration(args, RunMode.OTHER)
|
||||||
|
|
||||||
|
logger.debug('Starting freqtrade in cli-util mode')
|
||||||
|
|
||||||
|
if args.print_one_column:
|
||||||
|
print('\n'.join(supported_exchanges()))
|
||||||
|
else:
|
||||||
|
print(f"Supported exchanges: {', '.join(supported_exchanges())}")
|
Loading…
Reference in New Issue
Block a user