We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
--help produces traceback
Seems I broke it somehow.

`python3 freqtrade hyperopt --help`
produces traceback 
```
Fatal exception!
Traceback (most recent call last):
  File "/home/user/freqtrade-wrk/github-hroff-1902/freqtrade/freqtrade/main.py", line 42, in main
    args: Namespace = arguments.get_parsed_arg()
  File "/home/user/freqtrade-wrk/github-hroff-1902/freqtrade/freqtrade/arguments.py", line 46, in get_parsed_arg
    self.parsed_arg = self.parse_args()
  File "/home/user/freqtrade-wrk/github-hroff-1902/freqtrade/freqtrade/arguments.py", line 54, in parse_args
    parsed_arg = self.parser.parse_args(self.args)
  File "/usr/lib/python3.6/argparse.py", line 1743, in parse_args
    args, argv = self.parse_known_args(args, namespace)
  File "/usr/lib/python3.6/argparse.py", line 1775, in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)
  File "/usr/lib/python3.6/argparse.py", line 1963, in _parse_known_args
    positionals_end_index = consume_positionals(start_index)
  File "/usr/lib/python3.6/argparse.py", line 1940, in consume_positionals
    take_action(action, args)
  File "/usr/lib/python3.6/argparse.py", line 1849, in take_action
    action(self, namespace, argument_values, option_string)
  File "/usr/lib/python3.6/argparse.py", line 1146, in __call__
    subnamespace, arg_strings = parser.parse_known_args(arg_strings, None)
  File "/usr/lib/python3.6/argparse.py", line 1775, in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)
  File "/usr/lib/python3.6/argparse.py", line 1981, in _parse_known_args
    start_index = consume_optional(start_index)
  File "/usr/lib/python3.6/argparse.py", line 1921, in consume_optional
    take_action(action, args, option_string)
  File "/usr/lib/python3.6/argparse.py", line 1849, in take_action
    action(self, namespace, argument_values, option_string)
  File "/usr/lib/python3.6/argparse.py", line 1034, in __call__
    parser.exit()
  File "/usr/lib/python3.6/argparse.py", line 2389, in exit
    _sys.exit(status)
SystemExit: 0
```


--- 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/main.py`
Content:
```
1 #!/usr/bin/env python3
2 """
3 Main Freqtrade bot script.
4 Read the documentation to know what cli arguments you need.
5 """
6 
7 import sys
8 # check min. python version
9 if sys.version_info < (3, 6):
10     sys.exit("Freqtrade requires Python version >= 3.6")
11 
12 # flake8: noqa E402
13 import logging
14 from argparse import Namespace
15 from typing import List
16 
17 from freqtrade import OperationalException
18 from freqtrade.arguments import Arguments
19 from freqtrade.configuration import set_loggers
20 from freqtrade.worker import Worker
21 
22 
23 logger = logging.getLogger('freqtrade')
24 
25 
26 def main(sysargv: List[str] = None) -> None:
27     """
28     This function will initiate the bot and start the trading loop.
29     :return: None
30     """
31 
32     try:
33         set_loggers()
34 
35         worker = None
36         return_code = 1
37 
38         arguments = Arguments(
39             sysargv,
40             'Free, open source crypto trading bot'
41         )
42         args: Namespace = arguments.get_parsed_arg()
43 
44         # A subcommand has been issued.
45         # Means if Backtesting or Hyperopt have been called we exit the bot
46         if hasattr(args, 'func'):
47             args.func(args)
48             # TODO: fetch return_code as returned by the command function here
49             return_code = 0
50         else:
51             # Load and run worker
52             worker = Worker(args)
53             worker.run()
54 
55     except KeyboardInterrupt:
56         logger.info('SIGINT received, aborting ...')
57         return_code = 0
58     except OperationalException as e:
59         logger.error(str(e))
60         return_code = 2
61     except BaseException:
62         logger.exception('Fatal exception!')
63     finally:
64         if worker:
65             worker.exit()
66         sys.exit(return_code)
67 
68 
69 if __name__ == '__main__':
70     main()
71
```
--- 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/main.py b/freqtrade/main.py
--- a/freqtrade/main.py
+++ b/freqtrade/main.py
@@ -12,7 +12,7 @@
 # flake8: noqa E402
 import logging
 from argparse import Namespace
-from typing import List
+from typing import Any, List
 
 from freqtrade import OperationalException
 from freqtrade.arguments import Arguments
@@ -29,12 +29,11 @@
     :return: None
     """
 
+    return_code: Any = 1
+    worker = None
     try:
         set_loggers()
 
-        worker = None
-        return_code = 1
-
         arguments = Arguments(
             sysargv,
             'Free, open source crypto trading bot'
@@ -52,13 +51,15 @@
             worker = Worker(args)
             worker.run()
 
+    except SystemExit as e:
+        return_code = e
     except KeyboardInterrupt:
         logger.info('SIGINT received, aborting ...')
         return_code = 0
     except OperationalException as e:
         logger.error(str(e))
         return_code = 2
-    except BaseException:
+    except Exception:
         logger.exception('Fatal exception!')
     finally:
         if worker:

{"golden_diff": "diff --git a/freqtrade/main.py b/freqtrade/main.py\n--- a/freqtrade/main.py\n+++ b/freqtrade/main.py\n@@ -12,7 +12,7 @@\n # flake8: noqa E402\n import logging\n from argparse import Namespace\n-from typing import List\n+from typing import Any, List\n \n from freqtrade import OperationalException\n from freqtrade.arguments import Arguments\n@@ -29,12 +29,11 @@\n     :return: None\n     \"\"\"\n \n+    return_code: Any = 1\n+    worker = None\n     try:\n         set_loggers()\n \n-        worker = None\n-        return_code = 1\n-\n         arguments = Arguments(\n             sysargv,\n             'Free, open source crypto trading bot'\n@@ -52,13 +51,15 @@\n             worker = Worker(args)\n             worker.run()\n \n+    except SystemExit as e:\n+        return_code = e\n     except KeyboardInterrupt:\n         logger.info('SIGINT received, aborting ...')\n         return_code = 0\n     except OperationalException as e:\n         logger.error(str(e))\n         return_code = 2\n-    except BaseException:\n+    except Exception:\n         logger.exception('Fatal exception!')\n     finally:\n         if worker:\n", "issue": "--help produces traceback\nSeems I broke it somehow.\r\n\r\n`python3 freqtrade hyperopt --help`\r\nproduces traceback \r\n```\r\nFatal exception!\r\nTraceback (most recent call last):\r\n  File \"/home/user/freqtrade-wrk/github-hroff-1902/freqtrade/freqtrade/main.py\", line 42, in main\r\n    args: Namespace = arguments.get_parsed_arg()\r\n  File \"/home/user/freqtrade-wrk/github-hroff-1902/freqtrade/freqtrade/arguments.py\", line 46, in get_parsed_arg\r\n    self.parsed_arg = self.parse_args()\r\n  File \"/home/user/freqtrade-wrk/github-hroff-1902/freqtrade/freqtrade/arguments.py\", line 54, in parse_args\r\n    parsed_arg = self.parser.parse_args(self.args)\r\n  File \"/usr/lib/python3.6/argparse.py\", line 1743, in parse_args\r\n    args, argv = self.parse_known_args(args, namespace)\r\n  File \"/usr/lib/python3.6/argparse.py\", line 1775, in parse_known_args\r\n    namespace, args = self._parse_known_args(args, namespace)\r\n  File \"/usr/lib/python3.6/argparse.py\", line 1963, in _parse_known_args\r\n    positionals_end_index = consume_positionals(start_index)\r\n  File \"/usr/lib/python3.6/argparse.py\", line 1940, in consume_positionals\r\n    take_action(action, args)\r\n  File \"/usr/lib/python3.6/argparse.py\", line 1849, in take_action\r\n    action(self, namespace, argument_values, option_string)\r\n  File \"/usr/lib/python3.6/argparse.py\", line 1146, in __call__\r\n    subnamespace, arg_strings = parser.parse_known_args(arg_strings, None)\r\n  File \"/usr/lib/python3.6/argparse.py\", line 1775, in parse_known_args\r\n    namespace, args = self._parse_known_args(args, namespace)\r\n  File \"/usr/lib/python3.6/argparse.py\", line 1981, in _parse_known_args\r\n    start_index = consume_optional(start_index)\r\n  File \"/usr/lib/python3.6/argparse.py\", line 1921, in consume_optional\r\n    take_action(action, args, option_string)\r\n  File \"/usr/lib/python3.6/argparse.py\", line 1849, in take_action\r\n    action(self, namespace, argument_values, option_string)\r\n  File \"/usr/lib/python3.6/argparse.py\", line 1034, in __call__\r\n    parser.exit()\r\n  File \"/usr/lib/python3.6/argparse.py\", line 2389, in exit\r\n    _sys.exit(status)\r\nSystemExit: 0\r\n```\r\n\n", "before_files": [{"content": "#!/usr/bin/env python3\n\"\"\"\nMain Freqtrade bot script.\nRead the documentation to know what cli arguments you need.\n\"\"\"\n\nimport sys\n# check min. python version\nif sys.version_info < (3, 6):\n    sys.exit(\"Freqtrade requires Python version >= 3.6\")\n\n# flake8: noqa E402\nimport logging\nfrom argparse import Namespace\nfrom typing import List\n\nfrom freqtrade import OperationalException\nfrom freqtrade.arguments import Arguments\nfrom freqtrade.configuration import set_loggers\nfrom freqtrade.worker import Worker\n\n\nlogger = logging.getLogger('freqtrade')\n\n\ndef main(sysargv: List[str] = None) -> None:\n    \"\"\"\n    This function will initiate the bot and start the trading loop.\n    :return: None\n    \"\"\"\n\n    try:\n        set_loggers()\n\n        worker = None\n        return_code = 1\n\n        arguments = Arguments(\n            sysargv,\n            'Free, open source crypto trading bot'\n        )\n        args: Namespace = arguments.get_parsed_arg()\n\n        # A subcommand has been issued.\n        # Means if Backtesting or Hyperopt have been called we exit the bot\n        if hasattr(args, 'func'):\n            args.func(args)\n            # TODO: fetch return_code as returned by the command function here\n            return_code = 0\n        else:\n            # Load and run worker\n            worker = Worker(args)\n            worker.run()\n\n    except KeyboardInterrupt:\n        logger.info('SIGINT received, aborting ...')\n        return_code = 0\n    except OperationalException as e:\n        logger.error(str(e))\n        return_code = 2\n    except BaseException:\n        logger.exception('Fatal exception!')\n    finally:\n        if worker:\n            worker.exit()\n        sys.exit(return_code)\n\n\nif __name__ == '__main__':\n    main()\n", "path": "freqtrade/main.py"}], "after_files": [{"content": "#!/usr/bin/env python3\n\"\"\"\nMain Freqtrade bot script.\nRead the documentation to know what cli arguments you need.\n\"\"\"\n\nimport sys\n# check min. python version\nif sys.version_info < (3, 6):\n    sys.exit(\"Freqtrade requires Python version >= 3.6\")\n\n# flake8: noqa E402\nimport logging\nfrom argparse import Namespace\nfrom typing import Any, List\n\nfrom freqtrade import OperationalException\nfrom freqtrade.arguments import Arguments\nfrom freqtrade.configuration import set_loggers\nfrom freqtrade.worker import Worker\n\n\nlogger = logging.getLogger('freqtrade')\n\n\ndef main(sysargv: List[str] = None) -> None:\n    \"\"\"\n    This function will initiate the bot and start the trading loop.\n    :return: None\n    \"\"\"\n\n    return_code: Any = 1\n    worker = None\n    try:\n        set_loggers()\n\n        arguments = Arguments(\n            sysargv,\n            'Free, open source crypto trading bot'\n        )\n        args: Namespace = arguments.get_parsed_arg()\n\n        # A subcommand has been issued.\n        # Means if Backtesting or Hyperopt have been called we exit the bot\n        if hasattr(args, 'func'):\n            args.func(args)\n            # TODO: fetch return_code as returned by the command function here\n            return_code = 0\n        else:\n            # Load and run worker\n            worker = Worker(args)\n            worker.run()\n\n    except SystemExit as e:\n        return_code = e\n    except KeyboardInterrupt:\n        logger.info('SIGINT received, aborting ...')\n        return_code = 0\n    except OperationalException as e:\n        logger.error(str(e))\n        return_code = 2\n    except Exception:\n        logger.exception('Fatal exception!')\n    finally:\n        if worker:\n            worker.exit()\n        sys.exit(return_code)\n\n\nif __name__ == '__main__':\n    main()\n", "path": "freqtrade/main.py"}]}