We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
missing db_url for show_trades
Currently 
```
$ freqtrade show-trades
```
gives
```
...
2020-05-05 20:18:27,042 - freqtrade - ERROR - Fatal exception!
Traceback (most recent call last):
  File "/home/user/freqtrade-wrk/github-hroff-1902/freqtrade/freqtrade/main.py", line 36, in main
    return_code = args['func'](args)
  File "/home/user/freqtrade-wrk/github-hroff-1902/freqtrade/freqtrade/commands/list_commands.py", line 209, in start_show_trades
    init(config['db_url'], clean_open_orders=False)
KeyError: 'db_url'
```

Instead, a human-readable error message should be processed like for missing `--exchange` for `list-markets`:

```
freqtrade - ERROR - This command requires a configured exchange. You should either use `--exchange <exchange_name>` or specify a configuration file via `--config`.
```

-- similar should be printed for show_trades.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `freqtrade/commands/list_commands.py`
Content:
```
1 import csv
2 import logging
3 import sys
4 from collections import OrderedDict
5 from pathlib import Path
6 from typing import Any, Dict, List
7 
8 from colorama import init as colorama_init
9 from colorama import Fore, Style
10 import rapidjson
11 from tabulate import tabulate
12 
13 from freqtrade.configuration import setup_utils_configuration
14 from freqtrade.constants import USERPATH_HYPEROPTS, USERPATH_STRATEGIES
15 from freqtrade.exceptions import OperationalException
16 from freqtrade.exchange import (available_exchanges, ccxt_exchanges,
17                                 market_is_active, symbol_is_pair)
18 from freqtrade.misc import plural
19 from freqtrade.resolvers import ExchangeResolver, StrategyResolver
20 from freqtrade.state import RunMode
21 
22 logger = logging.getLogger(__name__)
23 
24 
25 def start_list_exchanges(args: Dict[str, Any]) -> None:
26     """
27     Print available exchanges
28     :param args: Cli args from Arguments()
29     :return: None
30     """
31     exchanges = ccxt_exchanges() if args['list_exchanges_all'] else available_exchanges()
32     if args['print_one_column']:
33         print('\n'.join(exchanges))
34     else:
35         if args['list_exchanges_all']:
36             print(f"All exchanges supported by the ccxt library: {', '.join(exchanges)}")
37         else:
38             print(f"Exchanges available for Freqtrade: {', '.join(exchanges)}")
39 
40 
41 def _print_objs_tabular(objs: List, print_colorized: bool) -> None:
42     if print_colorized:
43         colorama_init(autoreset=True)
44         red = Fore.RED
45         yellow = Fore.YELLOW
46         reset = Style.RESET_ALL
47     else:
48         red = ''
49         yellow = ''
50         reset = ''
51 
52     names = [s['name'] for s in objs]
53     objss_to_print = [{
54         'name': s['name'] if s['name'] else "--",
55         'location': s['location'].name,
56         'status': (red + "LOAD FAILED" + reset if s['class'] is None
57                    else "OK" if names.count(s['name']) == 1
58                    else yellow + "DUPLICATE NAME" + reset)
59     } for s in objs]
60 
61     print(tabulate(objss_to_print, headers='keys', tablefmt='psql', stralign='right'))
62 
63 
64 def start_list_strategies(args: Dict[str, Any]) -> None:
65     """
66     Print files with Strategy custom classes available in the directory
67     """
68     config = setup_utils_configuration(args, RunMode.UTIL_NO_EXCHANGE)
69 
70     directory = Path(config.get('strategy_path', config['user_data_dir'] / USERPATH_STRATEGIES))
71     strategy_objs = StrategyResolver.search_all_objects(directory, not args['print_one_column'])
72     # Sort alphabetically
73     strategy_objs = sorted(strategy_objs, key=lambda x: x['name'])
74 
75     if args['print_one_column']:
76         print('\n'.join([s['name'] for s in strategy_objs]))
77     else:
78         _print_objs_tabular(strategy_objs, config.get('print_colorized', False))
79 
80 
81 def start_list_hyperopts(args: Dict[str, Any]) -> None:
82     """
83     Print files with HyperOpt custom classes available in the directory
84     """
85     from freqtrade.resolvers.hyperopt_resolver import HyperOptResolver
86 
87     config = setup_utils_configuration(args, RunMode.UTIL_NO_EXCHANGE)
88 
89     directory = Path(config.get('hyperopt_path', config['user_data_dir'] / USERPATH_HYPEROPTS))
90     hyperopt_objs = HyperOptResolver.search_all_objects(directory, not args['print_one_column'])
91     # Sort alphabetically
92     hyperopt_objs = sorted(hyperopt_objs, key=lambda x: x['name'])
93 
94     if args['print_one_column']:
95         print('\n'.join([s['name'] for s in hyperopt_objs]))
96     else:
97         _print_objs_tabular(hyperopt_objs, config.get('print_colorized', False))
98 
99 
100 def start_list_timeframes(args: Dict[str, Any]) -> None:
101     """
102     Print ticker intervals (timeframes) available on Exchange
103     """
104     config = setup_utils_configuration(args, RunMode.UTIL_EXCHANGE)
105     # Do not use ticker_interval set in the config
106     config['ticker_interval'] = None
107 
108     # Init exchange
109     exchange = ExchangeResolver.load_exchange(config['exchange']['name'], config, validate=False)
110 
111     if args['print_one_column']:
112         print('\n'.join(exchange.timeframes))
113     else:
114         print(f"Timeframes available for the exchange `{exchange.name}`: "
115               f"{', '.join(exchange.timeframes)}")
116 
117 
118 def start_list_markets(args: Dict[str, Any], pairs_only: bool = False) -> None:
119     """
120     Print pairs/markets on the exchange
121     :param args: Cli args from Arguments()
122     :param pairs_only: if True print only pairs, otherwise print all instruments (markets)
123     :return: None
124     """
125     config = setup_utils_configuration(args, RunMode.UTIL_EXCHANGE)
126 
127     # Init exchange
128     exchange = ExchangeResolver.load_exchange(config['exchange']['name'], config, validate=False)
129 
130     # By default only active pairs/markets are to be shown
131     active_only = not args.get('list_pairs_all', False)
132 
133     base_currencies = args.get('base_currencies', [])
134     quote_currencies = args.get('quote_currencies', [])
135 
136     try:
137         pairs = exchange.get_markets(base_currencies=base_currencies,
138                                      quote_currencies=quote_currencies,
139                                      pairs_only=pairs_only,
140                                      active_only=active_only)
141         # Sort the pairs/markets by symbol
142         pairs = OrderedDict(sorted(pairs.items()))
143     except Exception as e:
144         raise OperationalException(f"Cannot get markets. Reason: {e}") from e
145 
146     else:
147         summary_str = ((f"Exchange {exchange.name} has {len(pairs)} ") +
148                        ("active " if active_only else "") +
149                        (plural(len(pairs), "pair" if pairs_only else "market")) +
150                        (f" with {', '.join(base_currencies)} as base "
151                         f"{plural(len(base_currencies), 'currency', 'currencies')}"
152                         if base_currencies else "") +
153                        (" and" if base_currencies and quote_currencies else "") +
154                        (f" with {', '.join(quote_currencies)} as quote "
155                         f"{plural(len(quote_currencies), 'currency', 'currencies')}"
156                         if quote_currencies else ""))
157 
158         headers = ["Id", "Symbol", "Base", "Quote", "Active",
159                    *(['Is pair'] if not pairs_only else [])]
160 
161         tabular_data = []
162         for _, v in pairs.items():
163             tabular_data.append({'Id': v['id'], 'Symbol': v['symbol'],
164                                  'Base': v['base'], 'Quote': v['quote'],
165                                  'Active': market_is_active(v),
166                                  **({'Is pair': symbol_is_pair(v['symbol'])}
167                                     if not pairs_only else {})})
168 
169         if (args.get('print_one_column', False) or
170                 args.get('list_pairs_print_json', False) or
171                 args.get('print_csv', False)):
172             # Print summary string in the log in case of machine-readable
173             # regular formats.
174             logger.info(f"{summary_str}.")
175         else:
176             # Print empty string separating leading logs and output in case of
177             # human-readable formats.
178             print()
179 
180         if len(pairs):
181             if args.get('print_list', False):
182                 # print data as a list, with human-readable summary
183                 print(f"{summary_str}: {', '.join(pairs.keys())}.")
184             elif args.get('print_one_column', False):
185                 print('\n'.join(pairs.keys()))
186             elif args.get('list_pairs_print_json', False):
187                 print(rapidjson.dumps(list(pairs.keys()), default=str))
188             elif args.get('print_csv', False):
189                 writer = csv.DictWriter(sys.stdout, fieldnames=headers)
190                 writer.writeheader()
191                 writer.writerows(tabular_data)
192             else:
193                 # print data as a table, with the human-readable summary
194                 print(f"{summary_str}:")
195                 print(tabulate(tabular_data, headers='keys', tablefmt='psql', stralign='right'))
196         elif not (args.get('print_one_column', False) or
197                   args.get('list_pairs_print_json', False) or
198                   args.get('print_csv', False)):
199             print(f"{summary_str}.")
200 
201 
202 def start_show_trades(args: Dict[str, Any]) -> None:
203     """
204     Show trades
205     """
206     from freqtrade.persistence import init, Trade
207     import json
208     config = setup_utils_configuration(args, RunMode.UTIL_NO_EXCHANGE)
209     init(config['db_url'], clean_open_orders=False)
210     tfilter = []
211 
212     if config.get('trade_ids'):
213         tfilter.append(Trade.id.in_(config['trade_ids']))
214 
215     trades = Trade.get_trades(tfilter).all()
216     logger.info(f"Printing {len(trades)} Trades: ")
217     if config.get('print_json', False):
218         print(json.dumps([trade.to_json() for trade in trades], indent=4))
219     else:
220         for trade in trades:
221             print(trade)
222
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/freqtrade/commands/list_commands.py b/freqtrade/commands/list_commands.py
--- a/freqtrade/commands/list_commands.py
+++ b/freqtrade/commands/list_commands.py
@@ -206,6 +206,11 @@
     from freqtrade.persistence import init, Trade
     import json
     config = setup_utils_configuration(args, RunMode.UTIL_NO_EXCHANGE)
+
+    if 'db_url' not in config:
+        raise OperationalException("--db-url is required for this command.")
+
+    logger.info(f'Using DB: "{config["db_url"]}"')
     init(config['db_url'], clean_open_orders=False)
     tfilter = []

{"golden_diff": "diff --git a/freqtrade/commands/list_commands.py b/freqtrade/commands/list_commands.py\n--- a/freqtrade/commands/list_commands.py\n+++ b/freqtrade/commands/list_commands.py\n@@ -206,6 +206,11 @@\n     from freqtrade.persistence import init, Trade\n     import json\n     config = setup_utils_configuration(args, RunMode.UTIL_NO_EXCHANGE)\n+\n+    if 'db_url' not in config:\n+        raise OperationalException(\"--db-url is required for this command.\")\n+\n+    logger.info(f'Using DB: \"{config[\"db_url\"]}\"')\n     init(config['db_url'], clean_open_orders=False)\n     tfilter = []\n", "issue": "missing db_url for show_trades\nCurrently \r\n```\r\n$ freqtrade show-trades\r\n```\r\ngives\r\n```\r\n...\r\n2020-05-05 20:18:27,042 - freqtrade - ERROR - Fatal exception!\r\nTraceback (most recent call last):\r\n  File \"/home/user/freqtrade-wrk/github-hroff-1902/freqtrade/freqtrade/main.py\", line 36, in main\r\n    return_code = args['func'](args)\r\n  File \"/home/user/freqtrade-wrk/github-hroff-1902/freqtrade/freqtrade/commands/list_commands.py\", line 209, in start_show_trades\r\n    init(config['db_url'], clean_open_orders=False)\r\nKeyError: 'db_url'\r\n```\r\n\r\nInstead, a human-readable error message should be processed like for missing `--exchange` for `list-markets`:\r\n\r\n```\r\nfreqtrade - ERROR - This command requires a configured exchange. You should either use `--exchange <exchange_name>` or specify a configuration file via `--config`.\r\n```\r\n\r\n-- similar should be printed for show_trades.\r\n\n", "before_files": [{"content": "import csv\nimport logging\nimport sys\nfrom collections import OrderedDict\nfrom pathlib import Path\nfrom typing import Any, Dict, List\n\nfrom colorama import init as colorama_init\nfrom colorama import Fore, Style\nimport rapidjson\nfrom tabulate import tabulate\n\nfrom freqtrade.configuration import setup_utils_configuration\nfrom freqtrade.constants import USERPATH_HYPEROPTS, USERPATH_STRATEGIES\nfrom freqtrade.exceptions import OperationalException\nfrom freqtrade.exchange import (available_exchanges, ccxt_exchanges,\n                                market_is_active, symbol_is_pair)\nfrom freqtrade.misc import plural\nfrom freqtrade.resolvers import ExchangeResolver, StrategyResolver\nfrom freqtrade.state import RunMode\n\nlogger = logging.getLogger(__name__)\n\n\ndef start_list_exchanges(args: Dict[str, Any]) -> None:\n    \"\"\"\n    Print available exchanges\n    :param args: Cli args from Arguments()\n    :return: None\n    \"\"\"\n    exchanges = ccxt_exchanges() if args['list_exchanges_all'] else available_exchanges()\n    if args['print_one_column']:\n        print('\\n'.join(exchanges))\n    else:\n        if args['list_exchanges_all']:\n            print(f\"All exchanges supported by the ccxt library: {', '.join(exchanges)}\")\n        else:\n            print(f\"Exchanges available for Freqtrade: {', '.join(exchanges)}\")\n\n\ndef _print_objs_tabular(objs: List, print_colorized: bool) -> None:\n    if print_colorized:\n        colorama_init(autoreset=True)\n        red = Fore.RED\n        yellow = Fore.YELLOW\n        reset = Style.RESET_ALL\n    else:\n        red = ''\n        yellow = ''\n        reset = ''\n\n    names = [s['name'] for s in objs]\n    objss_to_print = [{\n        'name': s['name'] if s['name'] else \"--\",\n        'location': s['location'].name,\n        'status': (red + \"LOAD FAILED\" + reset if s['class'] is None\n                   else \"OK\" if names.count(s['name']) == 1\n                   else yellow + \"DUPLICATE NAME\" + reset)\n    } for s in objs]\n\n    print(tabulate(objss_to_print, headers='keys', tablefmt='psql', stralign='right'))\n\n\ndef start_list_strategies(args: Dict[str, Any]) -> None:\n    \"\"\"\n    Print files with Strategy custom classes available in the directory\n    \"\"\"\n    config = setup_utils_configuration(args, RunMode.UTIL_NO_EXCHANGE)\n\n    directory = Path(config.get('strategy_path', config['user_data_dir'] / USERPATH_STRATEGIES))\n    strategy_objs = StrategyResolver.search_all_objects(directory, not args['print_one_column'])\n    # Sort alphabetically\n    strategy_objs = sorted(strategy_objs, key=lambda x: x['name'])\n\n    if args['print_one_column']:\n        print('\\n'.join([s['name'] for s in strategy_objs]))\n    else:\n        _print_objs_tabular(strategy_objs, config.get('print_colorized', False))\n\n\ndef start_list_hyperopts(args: Dict[str, Any]) -> None:\n    \"\"\"\n    Print files with HyperOpt custom classes available in the directory\n    \"\"\"\n    from freqtrade.resolvers.hyperopt_resolver import HyperOptResolver\n\n    config = setup_utils_configuration(args, RunMode.UTIL_NO_EXCHANGE)\n\n    directory = Path(config.get('hyperopt_path', config['user_data_dir'] / USERPATH_HYPEROPTS))\n    hyperopt_objs = HyperOptResolver.search_all_objects(directory, not args['print_one_column'])\n    # Sort alphabetically\n    hyperopt_objs = sorted(hyperopt_objs, key=lambda x: x['name'])\n\n    if args['print_one_column']:\n        print('\\n'.join([s['name'] for s in hyperopt_objs]))\n    else:\n        _print_objs_tabular(hyperopt_objs, config.get('print_colorized', False))\n\n\ndef start_list_timeframes(args: Dict[str, Any]) -> None:\n    \"\"\"\n    Print ticker intervals (timeframes) available on Exchange\n    \"\"\"\n    config = setup_utils_configuration(args, RunMode.UTIL_EXCHANGE)\n    # Do not use ticker_interval set in the config\n    config['ticker_interval'] = None\n\n    # Init exchange\n    exchange = ExchangeResolver.load_exchange(config['exchange']['name'], config, validate=False)\n\n    if args['print_one_column']:\n        print('\\n'.join(exchange.timeframes))\n    else:\n        print(f\"Timeframes available for the exchange `{exchange.name}`: \"\n              f\"{', '.join(exchange.timeframes)}\")\n\n\ndef start_list_markets(args: Dict[str, Any], pairs_only: bool = False) -> None:\n    \"\"\"\n    Print pairs/markets on the exchange\n    :param args: Cli args from Arguments()\n    :param pairs_only: if True print only pairs, otherwise print all instruments (markets)\n    :return: None\n    \"\"\"\n    config = setup_utils_configuration(args, RunMode.UTIL_EXCHANGE)\n\n    # Init exchange\n    exchange = ExchangeResolver.load_exchange(config['exchange']['name'], config, validate=False)\n\n    # By default only active pairs/markets are to be shown\n    active_only = not args.get('list_pairs_all', False)\n\n    base_currencies = args.get('base_currencies', [])\n    quote_currencies = args.get('quote_currencies', [])\n\n    try:\n        pairs = exchange.get_markets(base_currencies=base_currencies,\n                                     quote_currencies=quote_currencies,\n                                     pairs_only=pairs_only,\n                                     active_only=active_only)\n        # Sort the pairs/markets by symbol\n        pairs = OrderedDict(sorted(pairs.items()))\n    except Exception as e:\n        raise OperationalException(f\"Cannot get markets. Reason: {e}\") from e\n\n    else:\n        summary_str = ((f\"Exchange {exchange.name} has {len(pairs)} \") +\n                       (\"active \" if active_only else \"\") +\n                       (plural(len(pairs), \"pair\" if pairs_only else \"market\")) +\n                       (f\" with {', '.join(base_currencies)} as base \"\n                        f\"{plural(len(base_currencies), 'currency', 'currencies')}\"\n                        if base_currencies else \"\") +\n                       (\" and\" if base_currencies and quote_currencies else \"\") +\n                       (f\" with {', '.join(quote_currencies)} as quote \"\n                        f\"{plural(len(quote_currencies), 'currency', 'currencies')}\"\n                        if quote_currencies else \"\"))\n\n        headers = [\"Id\", \"Symbol\", \"Base\", \"Quote\", \"Active\",\n                   *(['Is pair'] if not pairs_only else [])]\n\n        tabular_data = []\n        for _, v in pairs.items():\n            tabular_data.append({'Id': v['id'], 'Symbol': v['symbol'],\n                                 'Base': v['base'], 'Quote': v['quote'],\n                                 'Active': market_is_active(v),\n                                 **({'Is pair': symbol_is_pair(v['symbol'])}\n                                    if not pairs_only else {})})\n\n        if (args.get('print_one_column', False) or\n                args.get('list_pairs_print_json', False) or\n                args.get('print_csv', False)):\n            # Print summary string in the log in case of machine-readable\n            # regular formats.\n            logger.info(f\"{summary_str}.\")\n        else:\n            # Print empty string separating leading logs and output in case of\n            # human-readable formats.\n            print()\n\n        if len(pairs):\n            if args.get('print_list', False):\n                # print data as a list, with human-readable summary\n                print(f\"{summary_str}: {', '.join(pairs.keys())}.\")\n            elif args.get('print_one_column', False):\n                print('\\n'.join(pairs.keys()))\n            elif args.get('list_pairs_print_json', False):\n                print(rapidjson.dumps(list(pairs.keys()), default=str))\n            elif args.get('print_csv', False):\n                writer = csv.DictWriter(sys.stdout, fieldnames=headers)\n                writer.writeheader()\n                writer.writerows(tabular_data)\n            else:\n                # print data as a table, with the human-readable summary\n                print(f\"{summary_str}:\")\n                print(tabulate(tabular_data, headers='keys', tablefmt='psql', stralign='right'))\n        elif not (args.get('print_one_column', False) or\n                  args.get('list_pairs_print_json', False) or\n                  args.get('print_csv', False)):\n            print(f\"{summary_str}.\")\n\n\ndef start_show_trades(args: Dict[str, Any]) -> None:\n    \"\"\"\n    Show trades\n    \"\"\"\n    from freqtrade.persistence import init, Trade\n    import json\n    config = setup_utils_configuration(args, RunMode.UTIL_NO_EXCHANGE)\n    init(config['db_url'], clean_open_orders=False)\n    tfilter = []\n\n    if config.get('trade_ids'):\n        tfilter.append(Trade.id.in_(config['trade_ids']))\n\n    trades = Trade.get_trades(tfilter).all()\n    logger.info(f\"Printing {len(trades)} Trades: \")\n    if config.get('print_json', False):\n        print(json.dumps([trade.to_json() for trade in trades], indent=4))\n    else:\n        for trade in trades:\n            print(trade)\n", "path": "freqtrade/commands/list_commands.py"}], "after_files": [{"content": "import csv\nimport logging\nimport sys\nfrom collections import OrderedDict\nfrom pathlib import Path\nfrom typing import Any, Dict, List\n\nfrom colorama import init as colorama_init\nfrom colorama import Fore, Style\nimport rapidjson\nfrom tabulate import tabulate\n\nfrom freqtrade.configuration import setup_utils_configuration\nfrom freqtrade.constants import USERPATH_HYPEROPTS, USERPATH_STRATEGIES\nfrom freqtrade.exceptions import OperationalException\nfrom freqtrade.exchange import (available_exchanges, ccxt_exchanges,\n                                market_is_active, symbol_is_pair)\nfrom freqtrade.misc import plural\nfrom freqtrade.resolvers import ExchangeResolver, StrategyResolver\nfrom freqtrade.state import RunMode\n\nlogger = logging.getLogger(__name__)\n\n\ndef start_list_exchanges(args: Dict[str, Any]) -> None:\n    \"\"\"\n    Print available exchanges\n    :param args: Cli args from Arguments()\n    :return: None\n    \"\"\"\n    exchanges = ccxt_exchanges() if args['list_exchanges_all'] else available_exchanges()\n    if args['print_one_column']:\n        print('\\n'.join(exchanges))\n    else:\n        if args['list_exchanges_all']:\n            print(f\"All exchanges supported by the ccxt library: {', '.join(exchanges)}\")\n        else:\n            print(f\"Exchanges available for Freqtrade: {', '.join(exchanges)}\")\n\n\ndef _print_objs_tabular(objs: List, print_colorized: bool) -> None:\n    if print_colorized:\n        colorama_init(autoreset=True)\n        red = Fore.RED\n        yellow = Fore.YELLOW\n        reset = Style.RESET_ALL\n    else:\n        red = ''\n        yellow = ''\n        reset = ''\n\n    names = [s['name'] for s in objs]\n    objss_to_print = [{\n        'name': s['name'] if s['name'] else \"--\",\n        'location': s['location'].name,\n        'status': (red + \"LOAD FAILED\" + reset if s['class'] is None\n                   else \"OK\" if names.count(s['name']) == 1\n                   else yellow + \"DUPLICATE NAME\" + reset)\n    } for s in objs]\n\n    print(tabulate(objss_to_print, headers='keys', tablefmt='psql', stralign='right'))\n\n\ndef start_list_strategies(args: Dict[str, Any]) -> None:\n    \"\"\"\n    Print files with Strategy custom classes available in the directory\n    \"\"\"\n    config = setup_utils_configuration(args, RunMode.UTIL_NO_EXCHANGE)\n\n    directory = Path(config.get('strategy_path', config['user_data_dir'] / USERPATH_STRATEGIES))\n    strategy_objs = StrategyResolver.search_all_objects(directory, not args['print_one_column'])\n    # Sort alphabetically\n    strategy_objs = sorted(strategy_objs, key=lambda x: x['name'])\n\n    if args['print_one_column']:\n        print('\\n'.join([s['name'] for s in strategy_objs]))\n    else:\n        _print_objs_tabular(strategy_objs, config.get('print_colorized', False))\n\n\ndef start_list_hyperopts(args: Dict[str, Any]) -> None:\n    \"\"\"\n    Print files with HyperOpt custom classes available in the directory\n    \"\"\"\n    from freqtrade.resolvers.hyperopt_resolver import HyperOptResolver\n\n    config = setup_utils_configuration(args, RunMode.UTIL_NO_EXCHANGE)\n\n    directory = Path(config.get('hyperopt_path', config['user_data_dir'] / USERPATH_HYPEROPTS))\n    hyperopt_objs = HyperOptResolver.search_all_objects(directory, not args['print_one_column'])\n    # Sort alphabetically\n    hyperopt_objs = sorted(hyperopt_objs, key=lambda x: x['name'])\n\n    if args['print_one_column']:\n        print('\\n'.join([s['name'] for s in hyperopt_objs]))\n    else:\n        _print_objs_tabular(hyperopt_objs, config.get('print_colorized', False))\n\n\ndef start_list_timeframes(args: Dict[str, Any]) -> None:\n    \"\"\"\n    Print ticker intervals (timeframes) available on Exchange\n    \"\"\"\n    config = setup_utils_configuration(args, RunMode.UTIL_EXCHANGE)\n    # Do not use ticker_interval set in the config\n    config['ticker_interval'] = None\n\n    # Init exchange\n    exchange = ExchangeResolver.load_exchange(config['exchange']['name'], config, validate=False)\n\n    if args['print_one_column']:\n        print('\\n'.join(exchange.timeframes))\n    else:\n        print(f\"Timeframes available for the exchange `{exchange.name}`: \"\n              f\"{', '.join(exchange.timeframes)}\")\n\n\ndef start_list_markets(args: Dict[str, Any], pairs_only: bool = False) -> None:\n    \"\"\"\n    Print pairs/markets on the exchange\n    :param args: Cli args from Arguments()\n    :param pairs_only: if True print only pairs, otherwise print all instruments (markets)\n    :return: None\n    \"\"\"\n    config = setup_utils_configuration(args, RunMode.UTIL_EXCHANGE)\n\n    # Init exchange\n    exchange = ExchangeResolver.load_exchange(config['exchange']['name'], config, validate=False)\n\n    # By default only active pairs/markets are to be shown\n    active_only = not args.get('list_pairs_all', False)\n\n    base_currencies = args.get('base_currencies', [])\n    quote_currencies = args.get('quote_currencies', [])\n\n    try:\n        pairs = exchange.get_markets(base_currencies=base_currencies,\n                                     quote_currencies=quote_currencies,\n                                     pairs_only=pairs_only,\n                                     active_only=active_only)\n        # Sort the pairs/markets by symbol\n        pairs = OrderedDict(sorted(pairs.items()))\n    except Exception as e:\n        raise OperationalException(f\"Cannot get markets. Reason: {e}\") from e\n\n    else:\n        summary_str = ((f\"Exchange {exchange.name} has {len(pairs)} \") +\n                       (\"active \" if active_only else \"\") +\n                       (plural(len(pairs), \"pair\" if pairs_only else \"market\")) +\n                       (f\" with {', '.join(base_currencies)} as base \"\n                        f\"{plural(len(base_currencies), 'currency', 'currencies')}\"\n                        if base_currencies else \"\") +\n                       (\" and\" if base_currencies and quote_currencies else \"\") +\n                       (f\" with {', '.join(quote_currencies)} as quote \"\n                        f\"{plural(len(quote_currencies), 'currency', 'currencies')}\"\n                        if quote_currencies else \"\"))\n\n        headers = [\"Id\", \"Symbol\", \"Base\", \"Quote\", \"Active\",\n                   *(['Is pair'] if not pairs_only else [])]\n\n        tabular_data = []\n        for _, v in pairs.items():\n            tabular_data.append({'Id': v['id'], 'Symbol': v['symbol'],\n                                 'Base': v['base'], 'Quote': v['quote'],\n                                 'Active': market_is_active(v),\n                                 **({'Is pair': symbol_is_pair(v['symbol'])}\n                                    if not pairs_only else {})})\n\n        if (args.get('print_one_column', False) or\n                args.get('list_pairs_print_json', False) or\n                args.get('print_csv', False)):\n            # Print summary string in the log in case of machine-readable\n            # regular formats.\n            logger.info(f\"{summary_str}.\")\n        else:\n            # Print empty string separating leading logs and output in case of\n            # human-readable formats.\n            print()\n\n        if len(pairs):\n            if args.get('print_list', False):\n                # print data as a list, with human-readable summary\n                print(f\"{summary_str}: {', '.join(pairs.keys())}.\")\n            elif args.get('print_one_column', False):\n                print('\\n'.join(pairs.keys()))\n            elif args.get('list_pairs_print_json', False):\n                print(rapidjson.dumps(list(pairs.keys()), default=str))\n            elif args.get('print_csv', False):\n                writer = csv.DictWriter(sys.stdout, fieldnames=headers)\n                writer.writeheader()\n                writer.writerows(tabular_data)\n            else:\n                # print data as a table, with the human-readable summary\n                print(f\"{summary_str}:\")\n                print(tabulate(tabular_data, headers='keys', tablefmt='psql', stralign='right'))\n        elif not (args.get('print_one_column', False) or\n                  args.get('list_pairs_print_json', False) or\n                  args.get('print_csv', False)):\n            print(f\"{summary_str}.\")\n\n\ndef start_show_trades(args: Dict[str, Any]) -> None:\n    \"\"\"\n    Show trades\n    \"\"\"\n    from freqtrade.persistence import init, Trade\n    import json\n    config = setup_utils_configuration(args, RunMode.UTIL_NO_EXCHANGE)\n\n    if 'db_url' not in config:\n        raise OperationalException(\"--db-url is required for this command.\")\n\n    logger.info(f'Using DB: \"{config[\"db_url\"]}\"')\n    init(config['db_url'], clean_open_orders=False)\n    tfilter = []\n\n    if config.get('trade_ids'):\n        tfilter.append(Trade.id.in_(config['trade_ids']))\n\n    trades = Trade.get_trades(tfilter).all()\n    logger.info(f\"Printing {len(trades)} Trades: \")\n    if config.get('print_json', False):\n        print(json.dumps([trade.to_json() for trade in trades], indent=4))\n    else:\n        for trade in trades:\n            print(trade)\n", "path": "freqtrade/commands/list_commands.py"}]}