Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
def update_tentacles_activation_config(new_config, deactivate_others=False):
    tentacles_setup_configuration = interfaces_util.get_edited_tentacles_config()
    try:
        updated_config = {
            element_name: activated if isinstance(activated, bool) else activated.lower() == "true"
            for element_name, activated in new_config.items()
        }
        if tentacles_manager_api.update_activation_configuration(interfaces_util.get_edited_tentacles_config(),
                                                                 updated_config, deactivate_others):
            tentacles_manager_api.save_tentacles_setup_configuration(tentacles_setup_configuration)
        return True
    except Exception as e:
        _get_logger().exception(e, True, f"Error when updating tentacles activation {e}")
        return False