def main(sysargv: List[str] = None) -> None: """ This function will initiate the bot and start the trading loop. :return: None """ return_code: Any = 1 worker = None try: arguments = Arguments(sysargv, 'Free, open source crypto trading bot') args: Namespace = arguments.get_parsed_arg() # A subcommand has been issued. # Means if Backtesting or Hyperopt have been called we exit the bot if hasattr(args, 'func'): args.func(args) # TODO: fetch return_code as returned by the command function here return_code = 0 else: # Load and run worker 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 Exception: logger.exception('Fatal exception!') finally: if worker: worker.exit() sys.exit(return_code)
def main(sysargv: List[str] = None) -> None: """ This function will initiate the bot and start the trading loop. :return: None """ return_code: Any = 1 try: arguments = Arguments(sysargv) args = arguments.get_parsed_arg() # Call subcommand. if 'func' in args: return_code = args['func'](args) else: # No subcommand was issued. raise OperationalException( "Usage of Freqtrade requires a subcommand to be specified.\n" "To have the previous behavior (bot executing trades in live/dry-run modes, " "depending on the value of the `dry_run` setting in the config), run freqtrade " "as `freqtrade trade [options...]`.\n" "To see the full list of options available, please use " "`freqtrade --help` or `freqtrade <command> --help`.") 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 Exception: logger.exception('Fatal exception!') finally: sys.exit(return_code)
def test_parse_args_none() -> None: arguments = Arguments([]) assert isinstance(arguments, Arguments) x = arguments.get_parsed_arg() assert isinstance(x, dict) assert isinstance(arguments.parser, argparse.ArgumentParser)