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
def is_compatible_account(exchange_name: str, api_key, api_sec, api_pass) -> dict: to_check_config = copy.deepcopy(interfaces_util.get_edited_config()[commons_constants.CONFIG_EXCHANGES].get(exchange_name, {})) if _is_real_exchange_value(api_key): to_check_config[commons_constants.CONFIG_EXCHANGE_KEY] = configuration.encrypt(api_key).decode() if _is_real_exchange_value(api_sec): to_check_config[commons_constants.CONFIG_EXCHANGE_SECRET] = configuration.encrypt(api_sec).decode() if _is_real_exchange_value(api_pass): to_check_config[commons_constants.CONFIG_EXCHANGE_PASSWORD] = configuration.encrypt(api_pass).decode() is_compatible = False is_sponsoring = trading_api.is_sponsoring(exchange_name) is_configured = False authenticator = interfaces_util.get_bot_api().get_community_auth() is_supporter = authenticator.supports.is_supporting() error = None if _is_possible_exchange_config(to_check_config): is_configured = True is_compatible, error = interfaces_util.run_in_bot_async_executor( trading_api.is_compatible_account( exchange_name, to_check_config, interfaces_util.get_edited_tentacles_config() ) ) return { "exchange": exchange_name, "compatible": is_compatible, "supporter_account": is_supporter, "configured": is_configured, "supporting": is_sponsoring, "error_message": error }
def get_exchanges_details(exchanges_config) -> dict: tentacles_setup_config = interfaces_util.get_edited_tentacles_config() return { exchange_name: { "has_websockets": trading_api.supports_websockets(exchange_name, tentacles_setup_config) } for exchange_name in exchanges_config }
def reset_config_to_default(tentacle_name): try: klass, _, _ = get_tentacle_from_string(tentacle_name, None, with_info=False) tentacles_manager_api.factory_tentacle_reset_config(interfaces_util.get_edited_tentacles_config(), klass) return True, f"{tentacle_name} configuration reset to default values" except Exception as e: _get_logger().exception(e, False) return False, f"Error when resetting factory tentacle config: {e}"
def update_tentacle_config(tentacle_name, config_update): try: klass, _, _ = get_tentacle_from_string(tentacle_name, None, with_info=False) tentacles_manager_api.update_tentacle_config(interfaces_util.get_edited_tentacles_config(), klass, config_update) return True, f"{tentacle_name} updated" except Exception as e: _get_logger().exception(e, False) return False, f"Error when updating tentacle config: {e}"
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 _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_evaluators_tentacles_activation(): return tentacles_manager_api.get_tentacles_activation( interfaces_util.get_edited_tentacles_config())[ tentacles_manager_constants.TENTACLES_EVALUATOR_PATH]
def get_tentacle_config(klass): return tentacles_manager_api.get_tentacle_config( interfaces_util.get_edited_tentacles_config(), klass)