def config_complete(self): config_map = load_required_configs() for key in self._get_empty_configs(): cvar = config_map.get(key) if cvar.value is None and cvar.required: return False return True
async def quick_start(): try: args = CmdlineParser().parse_args() strategy = args.strategy config_file_name = args.config_file_name wallet = args.wallet password = args.config_password await create_yml_files() init_logging("hummingbot_logs.yml") read_configs_from_yml() ExchangeRateConversion.get_instance().start() await ExchangeRateConversion.get_instance().wait_till_ready() hb = HummingbotApplication.main_application() in_memory_config_map.get("password").value = password in_memory_config_map.get("strategy").value = strategy in_memory_config_map.get("strategy").validate(strategy) in_memory_config_map.get("strategy_file_path").value = config_file_name in_memory_config_map.get("strategy_file_path").validate(config_file_name) # To ensure quickstart runs with the default value of False for kill_switch_enabled if not present if not global_config_map.get("kill_switch_enabled"): global_config_map.get("kill_switch_enabled").value = False if wallet and password: global_config_map.get("wallet").value = wallet hb.acct = unlock_wallet(public_key=wallet, password=password) if not hb.config_complete: config_map = load_required_configs() empty_configs = [key for key, config in config_map.items() if config.value is None and config.required] empty_config_description: str = "\n- ".join([""] + empty_configs) raise ValueError(f"Missing empty configs: {empty_config_description}\n") with patch_stdout(log_field=hb.app.log_field): dev_mode = check_dev_mode() if dev_mode: hb.app.log("Running from dev branches. Full remote logging will be enabled.") log_level = global_config_map.get("log_level").value init_logging("hummingbot_logs.yml", override_log_level=log_level, dev_mode=dev_mode, strategy_file_path=config_file_name) await write_config_to_yml() hb.start(log_level) tasks: List[Coroutine] = [hb.run()] if global_config_map.get("debug_console").value: management_port: int = detect_available_port(8211) tasks.append(start_management_console(locals(), host="localhost", port=management_port)) await safe_gather(*tasks) except Exception as e: # In case of quick start failure, start the bot normally to allow further configuration logging.getLogger().warning(f"Bot config incomplete: {str(e)}. Starting normally...") await normal_start()
def _get_empty_configs() -> List[str]: """ Returns a list of required config keys whose current value is None or an empty string. """ config_map = load_required_configs() return [ key for key, config in config_map.items() if config.value is None ]
def config_complete(self, # type: HummingbotApplication ): config_map = load_required_configs() keys = self.key_filter(self._get_empty_configs()) for key in keys: cvar = config_map.get(key) if cvar.value is None and cvar.required: return False return True
def config(self, key: str = None): self.app.clear_input() if key is not None and key not in load_required_configs().keys(): self.app.log("Invalid config variable %s" % (key, )) return if key is not None: keys = [key] else: keys = self._get_empty_configs() asyncio.ensure_future(self._config_loop(keys))
def config_complete(self, # type: HummingbotApplication ) -> bool: """ Returns bool value that indicates if the bot's configuration is all complete. """ config_map = load_required_configs() keys = self._get_empty_configs() for key in keys: cvar = config_map.get(key) if cvar.value is None and cvar.required: return False return True
def config(self, # type: HummingbotApplication key: str = None, key_list: Optional[List[str]] = None): self.app.clear_input() if self.strategy or (self.config_complete and key is None): asyncio.ensure_future(self.reset_config_loop(key)) return if key is not None and key not in load_required_configs().keys(): self._notify("Invalid config variable %s" % (key,)) return if key is not None: keys = [key] elif key_list is not None: keys = key_list else: keys = self._get_empty_configs() asyncio.ensure_future(self._config_loop(keys), loop=self.ev_loop)
def _get_empty_configs() -> List[str]: config_map = load_required_configs() return [ key for key, config in config_map.items() if config.value is None ]