Пример #1
0
 async def _prompt_missing_configs(
         self,  # type: HummingbotApplication
         config_map):
     missings = missing_required_configs(config_map)
     for config in missings:
         await self.prompt_a_config(config)
     if missing_required_configs(config_map):
         return missings + (await self._prompt_missing_configs(config_map))
     return missings
Пример #2
0
    async def _config_single_key(self,  # type: HummingbotApplication
                                 key: str,
                                 input_value):
        """
        Configure a single variable only.
        Prompt the user to finish all configurations if there are remaining empty configs at the end.
        """

        self.placeholder_mode = True
        self.app.hide_input = True

        try:
            config_var, config_map, file_path = None, None, None
            if key in global_config_map:
                config_map = global_config_map
                file_path = GLOBAL_CONFIG_PATH
            elif self.strategy_config_map is not None and key in self.strategy_config_map:
                config_map = self.strategy_config_map
                file_path = join(CONF_FILE_PATH, self.strategy_file_name)
            config_var = config_map[key]
            if input_value is None:
                self._notify("Please follow the prompt to complete configurations: ")
            if config_var.key == "inventory_target_base_pct":
                await self.asset_ratio_maintenance_prompt(config_map, input_value)
            elif config_var.key == "inventory_price":
                await self.inventory_price_prompt(config_map, input_value)
            else:
                await self.prompt_a_config(config_var, input_value=input_value, assign_default=False)
            if self.app.to_stop_config:
                self.app.to_stop_config = False
                return
            await self.update_all_secure_configs()
            missings = missing_required_configs(config_map)
            if missings:
                self._notify("\nThere are other configuration required, please follow the prompt to complete them.")
            missings = await self._prompt_missing_configs(config_map)
            save_to_yml(file_path, config_map)
            self._notify("\nNew configuration saved:")
            self._notify(f"{key}: {str(config_var.value)}")
            for config in missings:
                self._notify(f"{config.key}: {str(config.value)}")
            if isinstance(self.strategy, PureMarketMakingStrategy) or \
               isinstance(self.strategy, PerpetualMarketMakingStrategy):
                updated = ConfigCommand.update_running_mm(self.strategy, key, config_var.value)
                if updated:
                    self._notify(f"\nThe current {self.strategy_name} strategy has been updated "
                                 f"to reflect the new configuration.")
        except asyncio.TimeoutError:
            self.logger().error("Prompt timeout")
        except Exception as err:
            self.logger().error(str(err), exc_info=True)
        finally:
            self.app.hide_input = False
            self.placeholder_mode = False
            self.app.change_prompt(prompt=">>> ")
Пример #3
0
 def missing_configurations(self) -> List[str]:
     missing_globals = missing_required_configs(global_config_map)
     missing_configs = missing_required_configs(get_strategy_config_map(self.strategy_name))
     return missing_globals + missing_configs