def main(sysargv: List[str]) -> None: """ This function will initiate the bot and start the trading loop. :return: None """ 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) return worker = None return_code = 1 try: # Load and run worker worker = Worker(args) worker.run() except KeyboardInterrupt: logger.info('SIGINT received, aborting ...') return_code = 0 except OperationalException as e: logger.error(str(e)) return_code = 2 except BaseException: logger.exception('Fatal exception!') finally: if worker: worker.exit() sys.exit(return_code)
def start_trading(args: Dict[str, Any]) -> int: """ Main entry point for trading mode """ from freqtrade.worker import Worker # Load and run worker worker = None try: worker = Worker(args) worker.run() except KeyboardInterrupt: logger.info('SIGINT received, aborting ...') finally: if worker: logger.info("worker found ... calling exit") worker.exit() return 0
def start_trading(args: Dict[str, Any]) -> int: """ Main entry point for trading mode """ # Import here to avoid loading worker module when it's not used from freqtrade.worker import Worker # Create and run worker worker = None try: worker = Worker(args) worker.run() except Exception as e: logger.error(str(e)) logger.exception("Fatal exception!") except KeyboardInterrupt: logger.info('SIGINT received, aborting ...') finally: if worker: logger.info("worker found ... calling exit") worker.exit() return 0
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) 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)