def get_tentacles_activation_desc_by_group(media_url, missing_tentacles: set): tentacles_activation = tentacles_manager_api.get_tentacles_activation(interfaces_util.get_edited_tentacles_config()) startup_tentacles_activation = tentacles_manager_api.get_tentacles_activation( interfaces_util.get_startup_tentacles_config()) activation_by_group = {} for root_element in NON_TRADING_STRATEGY_RELATED_TENTACLES: try: _add_tentacles_activation_desc_for_group(activation_by_group, tentacles_activation, startup_tentacles_activation, root_element, media_url, missing_tentacles) except KeyError: pass # only return tentacle groups for which there is an activation choice to simplify the config interface return {group: tentacles for group, tentacles in activation_by_group.items() if len(tentacles) > 1}
def _update_tentacles_config(self, strategy_evaluator_class, trading_mode_class): default_evaluators = strategy_evaluator_class.get_default_evaluators( self.tentacles_setup_config) to_update_config = {} tentacles_activation = tentacles_manager_api.get_tentacles_activation( self.tentacles_setup_config) for tentacle_class_name in tentacles_activation[ tentacles_manager_constants.TENTACLES_EVALUATOR_PATH]: if commons_constants.CONFIG_WILDCARD not in default_evaluators and tentacle_class_name in default_evaluators: to_update_config[tentacle_class_name] = True elif tentacles_management.get_class_from_string( tentacle_class_name, evaluators.StrategyEvaluator, Strategies, tentacles_management. evaluator_parent_inspection) is not None: to_update_config[tentacle_class_name] = False elif commons_constants.CONFIG_WILDCARD not in default_evaluators: to_update_config[tentacle_class_name] = False for tentacle_class_name in tentacles_activation[ tentacles_manager_constants.TENTACLES_TRADING_PATH]: to_update_config[tentacle_class_name] = False # Add required elements if missing to_update_config.update( {evaluator: True for evaluator in default_evaluators}) to_update_config[strategy_evaluator_class.get_name()] = True to_update_config[trading_mode_class.get_name()] = True tentacles_manager_api.update_activation_configuration( self.tentacles_setup_config, to_update_config, False, add_missing_elements=True)
def _adapt_tentacles_config(self, activated_evaluators): # Lazy import of tentacles to let tentacles manager handle imports import tentacles.Evaluator as tentacles_Evaluator to_update_config = {} tentacles_activation = tentacles_manager_api.get_tentacles_activation(self.tentacles_setup_config) for tentacle_class_name in tentacles_activation[tentacles_manager_constants.TENTACLES_EVALUATOR_PATH]: if tentacle_class_name in activated_evaluators: to_update_config[tentacle_class_name] = True elif tentacles_management.get_class_from_string(tentacle_class_name, evaluators.StrategyEvaluator, tentacles_Evaluator.Strategies, tentacles_management.evaluator_parent_inspection) is None: to_update_config[tentacle_class_name] = False tentacles_manager_api.update_activation_configuration(self.tentacles_setup_config, to_update_config, False)
def _register_only_strategy(self, strategy_evaluator_class): try: import tentacles.Evaluator as Evaluator import octobot_evaluators.evaluators as evaluators tentacles_activation = tentacles_manager_api.get_tentacles_activation(self.tentacles_setup_config) for evaluator_name in tentacles_activation[tentacles_manager_constants.TENTACLES_EVALUATOR_PATH]: if tentacles_management.get_class_from_string( evaluator_name, evaluators.StrategyEvaluator, Evaluator.Strategies, tentacles_management.evaluator_parent_inspection) is not None: tentacles_activation[tentacles_manager_constants.TENTACLES_EVALUATOR_PATH][evaluator_name] = False tentacles_activation[tentacles_manager_constants.TENTACLES_EVALUATOR_PATH][ strategy_evaluator_class.get_name()] = True except ImportError as e: self.logger.error(f"Backtesting tests requires OctoBot-Evaluator package installed {e}")
def get_evaluators_tentacles_startup_activation(): return tentacles_manager_api.get_tentacles_activation( interfaces_util.get_startup_tentacles_config())[ tentacles_manager_constants.TENTACLES_EVALUATOR_PATH]
def _get_trading_tentacles_activation(): return tentacles_manager_api.get_tentacles_activation( interfaces_util.get_edited_tentacles_config())[ tentacles_manager_constants.TENTACLES_TRADING_PATH]
def _get_all_TA(self): return [evaluator for evaluator, activated in tentacles_manager_api.get_tentacles_activation(self.tentacles_setup_config)[ tentacles_manager_constants.TENTACLES_EVALUATOR_PATH].items() if activated and StrategyOptimizer._is_relevant_evaluation_config(evaluator)]