async def prompt_a_config( self, # type: HummingbotApplication model: ClientConfigAdapter, config: str, input_value=None, assign_default=True, ): config_path = config.split(".") while len(config_path) != 1: sub_model_attr = config_path.pop(0) model = getattr(model, sub_model_attr) config = config_path[0] if input_value is None: prompt = await model.get_client_prompt(config) if prompt is not None: if assign_default: default = model.get_default(config) default = str(default) if default is not None else "" self.app.set_text(default) prompt = f"{prompt} >>> " client_data = model.get_client_data(config) input_value = await self.app.prompt(prompt=prompt, is_password=client_data.is_secure) new_config_value = None if not self.app.to_stop_config and input_value is not None: try: setattr(model, config, input_value) new_config_value = getattr(model, config) except ConfigValidationError as e: self.notify(str(e)) new_config_value = await self.prompt_a_config(model, config) if not self.app.to_stop_config and isinstance(new_config_value, ClientConfigAdapter): await self.prompt_for_model_config(new_config_value)
async def prompt_for_model_config( self, # type: HummingbotApplication config_map: ClientConfigAdapter, ): for key in config_map.keys(): client_data = config_map.get_client_data(key) if ( client_data is not None and (client_data.prompt_on_new or config_map.is_required(key)) ): await self.prompt_a_config(config_map, key) if self.app.to_stop_config: break
def build_config_map(cm: ClientConfigAdapter, cs: Dict): """This routine can be used in the create command, with slight modifications.""" for key in cm.keys(): client_data = cm.get_client_data(key) if client_data is not None and client_data.prompt_on_new: self.assertIsInstance(client_data.prompt(cm), str) if key == "execution_timeframe_model": setattr(cm, key, "daily_between_times") # simulate user input else: setattr(cm, key, cs[key]) new_value = getattr(cm, key) if isinstance(new_value, ClientConfigAdapter): build_config_map(new_value, cs[key])