Beispiel #1
0
 def load_config(self):
     # try with this class name
     self.specific_config = api.get_tentacle_config(self.tentacles_setup_config, self.__class__)
     if not self.specific_config:
         # if nothing in config, try with any super-class' config file
         for super_class in self.get_parent_evaluator_classes(SocialEvaluator):
             self.specific_config = api.get_tentacle_config(self.tentacles_setup_config, super_class)
             if self.specific_config:
                 return
     # set default config if nothing found
     if not self.specific_config:
         self.set_default_config()
Beispiel #2
0
 def __init__(self, tentacles_setup_config):
     super().__init__(tentacles_setup_config)
     self.config = tentacles_manager_api.get_tentacle_config(
         tentacles_setup_config, self.__class__)
     self.factor = self.config.get(self.FACTOR, 3)
     self.length = self.config.get(self.LENGTH, 10)
     self.eval_note = commons_constants.START_PENDING_EVAL_NOTE
     self.previous_value = {}
    def load_config(self) -> None:
        # try with this class name
        self.trading_config = tentacles_manager_api.get_tentacle_config(
            self.exchange_manager.tentacles_setup_config, self.__class__)

        # set default config if nothing found
        if not self.trading_config:
            self.set_default_config()
Beispiel #4
0
 def get_is_trading_on_exchange(cls, exchange_name) -> bool:
     """
     :return: True if exchange_name is in exchanges_to_trade_on (case insensitive)
     or if exchanges_to_trade_on is missing or empty
     """
     exchanges_to_trade_on = tentacles_manager_api.get_tentacle_config(cls).get("exchanges_to_trade_on", [])
     return not exchanges_to_trade_on or exchange_name.lower() in [exchange.lower()
                                                                   for exchange in exchanges_to_trade_on]
Beispiel #5
0
 def __init__(self, tentacles_setup_config):
     super().__init__(tentacles_setup_config)
     self.config = tentacles_manager_api.get_tentacle_config(
         tentacles_setup_config, self.__class__)
     self.fast_length = self.config.get(self.FAST_LENGTH, 50)
     self.slow_length = self.config.get(self.SLOW_LENGTH, 200)
     self.fast_ma_type = self.config.get(self.FAST_MA_TYPE, "SMA").lower()
     self.slow_ma_type = self.config.get(self.SLOW_MA_TYPE, "SMA").lower()
     self.eval_note = commons_constants.START_PENDING_EVAL_NOTE
Beispiel #6
0
 def get_required_time_frames(cls, config: dict,
                              tentacles_setup_config: tm_configuration.TentaclesSetupConfiguration):
     if constants.CONFIG_FORCED_TIME_FRAME in config:
         return time_frame_manager.parse_time_frames(config[constants.CONFIG_FORCED_TIME_FRAME])
     strategy_config: dict = api.get_tentacle_config(tentacles_setup_config, cls)
     if constants.STRATEGIES_REQUIRED_TIME_FRAME in strategy_config:
         return time_frame_manager.parse_time_frames(strategy_config[constants.STRATEGIES_REQUIRED_TIME_FRAME])
     else:
         raise Exception(f"'{constants.STRATEGIES_REQUIRED_TIME_FRAME}' is missing in configuration file")
Beispiel #7
0
 def get_default_evaluators(cls, tentacles_config: tm_configuration.TentaclesSetupConfiguration,
                            strategy_config: dict = None):
     strategy_config: dict = strategy_config or api.get_tentacle_config(tentacles_config, cls)
     if constants.TENTACLE_DEFAULT_CONFIG in strategy_config:
         return strategy_config[constants.TENTACLE_DEFAULT_CONFIG]
     else:
         required_evaluators = cls.get_required_evaluators(tentacles_config, strategy_config)
         if required_evaluators == common_constants.CONFIG_WILDCARD:
             return []
         return required_evaluators
Beispiel #8
0
 def get_compatible_evaluators_types(cls, tentacles_config: tm_configuration.TentaclesSetupConfiguration,
                                     strategy_config: dict = None) -> list:
     """
     :param tentacles_config: the tentacles config to find the current strategy config from
     :param strategy_config: the strategy configuration dict
     :return: the list of compatible evaluator type, [CONFIG_WILDCARD] means any type
     """
     strategy_config: dict = strategy_config or api.get_tentacle_config(tentacles_config, cls)
     if constants.STRATEGIES_COMPATIBLE_EVALUATOR_TYPES in strategy_config:
         return strategy_config[constants.STRATEGIES_COMPATIBLE_EVALUATOR_TYPES]
     return [common_constants.CONFIG_WILDCARD]
    def load_config(self) -> None:
        """
        Try to load Supervisor tentacle config.
        Calls set_default_config() if the tentacle config is empty
        """
        # try with this class name
        self.supervisor_config = tentacles_manager_api.get_tentacle_config(
            self.exchange_manager.tentacles_setup_config, self.__class__)

        # set default config if nothing found
        if not self.supervisor_config:
            self.set_default_config()
Beispiel #10
0
 def get_required_evaluators(cls, tentacles_config: tm_configuration.TentaclesSetupConfiguration,
                             strategy_config: dict = None) -> list:
     """
     :param tentacles_config: the tentacles config to find the current strategy config from
     :param strategy_config: the strategy configuration dict
     :return: the list of required evaluators, [CONFIG_WILDCARD] means any evaluator
     """
     strategy_config: dict = strategy_config or api.get_tentacle_config(tentacles_config, cls)
     if constants.STRATEGIES_REQUIRED_EVALUATORS in strategy_config:
         return strategy_config[constants.STRATEGIES_REQUIRED_EVALUATORS]
     else:
         raise Exception(f"'{constants.STRATEGIES_REQUIRED_EVALUATORS}' is missing in configuration file")
    def get_default_strategies(
            cls,
            tentacles_config: tm_configuration.TentaclesSetupConfiguration,
            trading_mode_config=None):
        config = trading_mode_config or tentacles_manager_api.get_tentacle_config(
            tentacles_config, cls)
        if common_constants.TENTACLE_DEFAULT_CONFIG in config:
            return config[common_constants.TENTACLE_DEFAULT_CONFIG]

        strategies_classes, _ = cls.get_required_strategies_names_and_count(
            tentacles_config, config)
        return strategies_classes
 def get_required_strategies_names_and_count(
         cls,
         tentacles_config: tm_configuration.TentaclesSetupConfiguration,
         trading_mode_config=None):
     config = trading_mode_config or tentacles_manager_api.get_tentacle_config(
         tentacles_config, cls)
     if constants.TRADING_MODE_REQUIRED_STRATEGIES in config:
         return config[
             constants.
             TRADING_MODE_REQUIRED_STRATEGIES], cls.get_required_strategies_count(
                 config)
     raise Exception(
         f"'{constants.TRADING_MODE_REQUIRED_STRATEGIES}' is missing in configuration file"
     )
Beispiel #13
0
    def __init__(self, tentacles_setup_config):
        super().__init__(tentacles_setup_config)
        self.evaluator_config = tentacles_manager_api.get_tentacle_config(self.tentacles_setup_config, self.__class__)
        self.period_length = self.evaluator_config[self.PERIOD]
        self.slow_eval_count = self.evaluator_config[self.SLOW_EVAL_COUNT]
        self.fast_eval_count = self.evaluator_config[self.FAST_EVAL_COUNT]

        try:
            # ensure rsi weights are sorted
            self.weights = sorted(self.evaluator_config[self.RSI_TO_WEIGHTS], key=lambda a: a[self.SLOW_THRESHOLD])
            for i, fast_threshold in enumerate(self.weights):
                fast_threshold[self.FAST_THRESHOLDS] = sorted(fast_threshold[self.FAST_THRESHOLDS],
                                                              key=lambda a: a[self.FAST_THRESHOLD])
        except KeyError as e:
            raise error.ConfigError(f"Error when reading config: {e}")
Beispiel #14
0
 def load_config(self):
     self.set_default_config()
     self.specific_config.update(
         api.get_tentacle_config(self.tentacles_setup_config,
                                 self.__class__))
Beispiel #15
0
def get_tentacle_config(klass):
    return tentacles_manager_api.get_tentacle_config(
        interfaces_util.get_edited_tentacles_config(), klass)
def get_tentacle_config(klass):
    return tentacles_manager_api.get_tentacle_config(klass)
Beispiel #17
0
 def __init__(self, tentacles_setup_config):
     super().__init__(tentacles_setup_config)
     self.evaluator_config = tentacles_manager_api.get_tentacle_config(
         self.tentacles_setup_config, self.__class__)
 def get_required_candles_count(cls,
                                tentacles_setup_config: tm_configuration.
                                TentaclesSetupConfiguration):
     return api.get_tentacle_config(tentacles_setup_config, cls).get(
         common_constants.CONFIG_TENTACLES_REQUIRED_CANDLES_COUNT, -1)
Beispiel #19
0
 def __init__(self):
     super().__init__()
     self.evaluation_time_frame = \
         commons_enums.TimeFrames(tentacles_manager_api.get_tentacle_config(self.__class__)[
                                      evaluator_constants.STRATEGIES_REQUIRED_TIME_FRAME][0]).value
Beispiel #20
0
 def __init__(self, tentacles_setup_config):
     super().__init__(tentacles_setup_config)
     self.evaluator_config = tentacles_manager_api.get_tentacle_config(
         self.tentacles_setup_config, self.__class__)
     self.period = self.evaluator_config[self.STOCHRSI_PERIOD]
Beispiel #21
0
 def __init__(self):
     super().__init__()
     self.evaluator_config = tentacles_manager_api.get_tentacle_config(
         self.__class__)
     self.period = self.evaluator_config[self.EMA_SIZE]