async def import_config_file( self, # type: HummingbotApplication file_name): self.app.clear_input() self.placeholder_mode = True self.app.hide_input = True required_exchanges.clear() if file_name is None: file_name = await self.prompt_a_file_name() if self.app.to_stop_config: self.app.to_stop_config = False return strategy_path = os.path.join(CONF_FILE_PATH, file_name) strategy = await update_strategy_config_map_from_file(strategy_path) self.strategy_file_name = file_name self.strategy_name = strategy self.notify( f"Configuration from {self.strategy_file_name} file is imported.") self.placeholder_mode = False self.app.hide_input = False self.app.change_prompt(prompt=">>> ") try: all_status_go = await self.status_check_all() except asyncio.TimeoutError: self.strategy_file_name = None self.strategy_name = None raise if all_status_go: self.notify("\nEnter \"start\" to start market making.") autofill_import = global_config_map.get("autofill_import").value if autofill_import is not None: self.app.set_text(autofill_import)
async def prompt_for_configuration(self, # type: HummingbotApplication file_name): self.app.clear_input() self.placeholder_mode = True self.app.hide_input = True required_exchanges.clear() strategy_config = ConfigVar(key="strategy", prompt="What is your market making strategy? >>> ", validator=validate_strategy) await self.prompt_a_config(strategy_config) if self.app.to_stop_config: self.app.to_stop_config = False return strategy = strategy_config.value config_map = get_strategy_config_map(strategy) self._notify(f"Please see https://docs.hummingbot.io/strategies/{strategy.replace('_', '-')}/ " f"while setting up these below configuration.") # assign default values and reset those not required for config in config_map.values(): if config.required: config.value = config.default else: config.value = None for config in config_map.values(): if config.prompt_on_new and config.required: if not self.app.to_stop_config: await self.prompt_a_config(config) else: self.app.to_stop_config = False return else: config.value = config.default # catch a last key binding to stop config, if any if self.app.to_stop_config: self.app.to_stop_config = False return if file_name is None: file_name = await self.prompt_new_file_name(strategy) if self.app.to_stop_config: self.app.to_stop_config = False self.app.set_text("") return self.app.change_prompt(prompt=">>> ") strategy_path = os.path.join(CONF_FILE_PATH, file_name) template = get_strategy_template_path(strategy) shutil.copy(template, strategy_path) save_to_yml(strategy_path, config_map) self.strategy_file_name = file_name self.strategy_name = strategy # Reload completer here otherwise the new file will not appear self.app.input_field.completer = load_completer(self) self._notify(f"A new config file {self.strategy_file_name} created.") self.placeholder_mode = False self.app.hide_input = False if await self.status_check_all(): self._notify("\nEnter \"start\" to start market making.")
async def import_config_file(self, # type: HummingbotApplication file_name): self.app.clear_input() self.placeholder_mode = True self.app.hide_input = True required_exchanges.clear() if file_name is None: file_name = await self.prompt_a_file_name() strategy_path = os.path.join(CONF_FILE_PATH, file_name) strategy = update_strategy_config_map_from_file(strategy_path) self.strategy_file_name = file_name self.strategy_name = strategy self._notify(f"Configuration from {self.strategy_file_name} file is imported.") self.placeholder_mode = False self.app.hide_input = False self.app.change_prompt(prompt=">>> ") if await self.status_check_all(): self._notify("\nEnter \"start\" to start market making.") self.app.set_text("start")
async def prompt_for_configuration( self, # type: HummingbotApplication file_name, ): self.app.clear_input() self.placeholder_mode = True self.app.hide_input = True required_exchanges.clear() strategy = await self.get_strategy_name() if self.app.to_stop_config: return config_map = get_strategy_config_map(strategy) self.notify(f"Please see https://docs.hummingbot.io/strategies/{strategy.replace('_', '-')}/ " f"while setting up these below configuration.") if isinstance(config_map, ClientConfigAdapter): await self.prompt_for_model_config(config_map) if not self.app.to_stop_config: file_name = await self.save_config_to_file(file_name, config_map) elif config_map is not None: file_name = await self.prompt_for_configuration_legacy(file_name, strategy, config_map) else: self.app.to_stop_config = True if self.app.to_stop_config: return save_previous_strategy_value(file_name, self.client_config_map) self.strategy_file_name = file_name self.strategy_name = strategy self.strategy_config_map = config_map # Reload completer here otherwise the new file will not appear self.app.input_field.completer = load_completer(self) self.notify(f"A new config file has been created: {self.strategy_file_name}") self.placeholder_mode = False self.app.hide_input = False await self.verify_status()
async def import_config_file( self, # type: HummingbotApplication file_name): self.app.clear_input() self.placeholder_mode = True self.app.hide_input = True required_exchanges.clear() if file_name is None: file_name = await self.prompt_a_file_name() if file_name is not None: save_previous_strategy_value(file_name, self.client_config_map) if self.app.to_stop_config: self.app.to_stop_config = False return strategy_path = STRATEGIES_CONF_DIR_PATH / file_name config_map = await load_strategy_config_map_from_file(strategy_path) self.strategy_file_name = file_name self.strategy_name = ( config_map.strategy if not isinstance(config_map, dict) else config_map.get("strategy").value # legacy ) self.strategy_config_map = config_map self.notify( f"Configuration from {self.strategy_file_name} file is imported.") self.placeholder_mode = False self.app.hide_input = False self.app.change_prompt(prompt=">>> ") try: all_status_go = await self.status_check_all() except asyncio.TimeoutError: self.strategy_file_name = None self.strategy_name = None self.strategy_config_map = None raise if all_status_go: self.notify("\nEnter \"start\" to start market making.") autofill_import = self.client_config_map.autofill_import if autofill_import != AutofillImportEnum.disabled: self.app.set_text(autofill_import)
def tearDown(self) -> None: self.reset_config_map() required_exchanges.clear() super().tearDown()
def setUp(self) -> None: super().setUp() required_exchanges.clear() self.config_backup = deepcopy(fixed_grid_config_map)
async def prompt_for_configuration( self, # type: HummingbotApplication file_name): self.app.clear_input() self.placeholder_mode = True self.app.hide_input = True required_exchanges.clear() strategy_config = ConfigVar( key="strategy", prompt="What is your market making strategy? >>> ", validator=validate_strategy) await self.prompt_a_config(strategy_config) if self.app.to_stop_config: self.stop_config() return strategy = strategy_config.value config_map = get_strategy_config_map(strategy) config_map_backup = copy.deepcopy(config_map) self._notify( f"Please see https://docs.hummingbot.io/strategies/{strategy.replace('_', '-')}/ " f"while setting up these below configuration.") # assign default values and reset those not required for config in config_map.values(): if config.required: config.value = config.default else: config.value = None for config in config_map.values(): if config.prompt_on_new and config.required: if not self.app.to_stop_config: await self.prompt_a_config(config) else: break else: config.value = config.default if self.app.to_stop_config: self.stop_config(config_map, config_map_backup) return if file_name is None: file_name = await self.prompt_new_file_name(strategy) if self.app.to_stop_config: self.stop_config(config_map, config_map_backup) self.app.set_text("") return self.app.change_prompt(prompt=">>> ") strategy_path = os.path.join(CONF_FILE_PATH, file_name) template = get_strategy_template_path(strategy) shutil.copy(template, strategy_path) save_to_yml(strategy_path, config_map) self.strategy_file_name = file_name self.strategy_name = strategy # Reload completer here otherwise the new file will not appear self.app.input_field.completer = load_completer(self) self._notify(f"A new config file {self.strategy_file_name} created.") self.placeholder_mode = False self.app.hide_input = False try: timeout = float(global_config_map["create_command_timeout"].value) all_status_go = await asyncio.wait_for(self.status_check_all(), timeout) except asyncio.TimeoutError: self._notify( "\nA network error prevented the connection check to complete. See logs for more details." ) self.strategy_file_name = None self.strategy_name = None raise if all_status_go: self._notify("\nEnter \"start\" to start market making.")