Beispiel #1
0
    def test_strategy_config_template_complete(self):
        folder: str = join(root_path(), "hummingbot/strategy")
        # Only include valid directories
        strategies = [
            d for d in listdir(folder)
            if isdir(join(folder, d)) and not d.startswith("__")
            and exists(join(folder, d, "__init__.py"))
        ]
        strategies.sort()

        for strategy in strategies:
            strategy_template_path: str = get_strategy_template_path(strategy)
            strategy_config_map = get_strategy_config_map(strategy)

            with open(strategy_template_path, "r") as template_fd:
                template_data = yaml_parser.load(template_fd)
                template_version = template_data.get("template_version", 0)
                self.assertGreaterEqual(
                    template_version, 1,
                    f"Template version too low at {strategy_template_path}")
                for key in template_data:
                    if key == "template_version":
                        continue
                    self.assertTrue(key in strategy_config_map,
                                    f"{key} not in {strategy}_config_map")

                for key in strategy_config_map:
                    self.assertTrue(key in template_data,
                                    f"{key} not in {strategy_template_path}")
Beispiel #2
0
    def test_global_config_template_complete(self):
        global_config_template_path: str = join(
            root_path(), "hummingbot/templates/conf_global_TEMPLATE.yml")

        with open(global_config_template_path, "r") as template_fd:
            template_data = yaml_parser.load(template_fd)
            template_version = template_data.get("template_version", 0)
            self.assertGreaterEqual(template_version, 1)
            for key in template_data:
                if key == "template_version":
                    continue
                self.assertTrue(key in global_config_map,
                                f"{key} not in global_config_map")

            for key in global_config_map:
                self.assertTrue(key in template_data,
                                f"{key} not in {global_config_template_path}")
Beispiel #3
0
def get_strategy_pydantic_config_cls(
        strategy_name: str) -> Optional[ModelMetaclass]:
    pydantic_cm_class = None
    try:
        pydantic_cm_pkg = f"{strategy_name}_config_map_pydantic"
        pydantic_cm_path = root_path(
        ) / "hummingbot" / "strategy" / strategy_name / f"{pydantic_cm_pkg}.py"
        if pydantic_cm_path.exists():
            pydantic_cm_class_name = f"{''.join([s.capitalize() for s in strategy_name.split('_')])}ConfigMap"
            pydantic_cm_mod = __import__(
                f"hummingbot.strategy.{strategy_name}.{pydantic_cm_pkg}",
                fromlist=[f"{pydantic_cm_class_name}"])
            pydantic_cm_class = getattr(pydantic_cm_mod,
                                        pydantic_cm_class_name)
    except ImportError:
        logging.getLogger().exception(
            f"Could not import Pydantic configs for {strategy_name}.")
    return pydantic_cm_class
if TYPE_CHECKING:
    from hummingbot.client.config.config_data_types import BaseConnectorConfigMap
    from hummingbot.connector.connector_base import ConnectorBase

# Global variables
required_exchanges: Set[str] = set()
requried_connector_trading_pairs: Dict[str, List[str]] = {}
# Set these two variables if a strategy uses oracle for rate conversion
required_rate_oracle: bool = False
rate_oracle_pairs: List[str] = []

# Global static values
KEYFILE_PREFIX = "key_file_"
KEYFILE_POSTFIX = ".yml"
ENCYPTED_CONF_POSTFIX = ".json"
DEFAULT_LOG_FILE_PATH = root_path() / "logs"
DEFAULT_ETHEREUM_RPC_URL = "https://mainnet.coinalpha.com/hummingbot-test-node"
TEMPLATE_PATH = root_path() / "hummingbot" / "templates"
CONF_DIR_PATH = root_path() / "conf"
CLIENT_CONFIG_PATH = CONF_DIR_PATH / "conf_client.yml"
TRADE_FEES_CONFIG_PATH = CONF_DIR_PATH / "conf_fee_overrides.yml"
STRATEGIES_CONF_DIR_PATH = CONF_DIR_PATH / "strategies"
CONNECTORS_CONF_DIR_PATH = CONF_DIR_PATH / "connectors"
CONF_PREFIX = "conf_"
CONF_POSTFIX = "_strategy"
PMM_SCRIPTS_PATH = root_path() / "pmm_scripts"
SCRIPT_STRATEGIES_MODULE = "scripts"
SCRIPT_STRATEGIES_PATH = root_path() / SCRIPT_STRATEGIES_MODULE
CERTS_PATH = root_path() / "certs"

# Certificates for securely communicating with the gateway api
import os
import sys
from os.path import dirname, join, realpath
from typing import Type

from prompt_toolkit.shortcuts import input_dialog, message_dialog
from prompt_toolkit.styles import Style

from hummingbot import root_path
from hummingbot.client.config.conf_migration import migrate_configs, migrate_non_secure_configs_only
from hummingbot.client.config.config_crypt import BaseSecretsManager, store_password_verification
from hummingbot.client.config.security import Security
from hummingbot.client.settings import CONF_DIR_PATH

sys.path.insert(0, str(root_path()))

with open(realpath(join(dirname(__file__), '../../VERSION'))) as version_file:
    version = version_file.read().strip()


def login_prompt(secrets_manager_cls: Type[BaseSecretsManager], style: Style):
    err_msg = None
    secrets_manager = None
    if Security.new_password_required() and legacy_confs_exist():
        secrets_manager = migrate_configs_prompt(secrets_manager_cls, style)
    if Security.new_password_required():
        show_welcome(style)
        password = input_dialog(title="Set Password",
                                text="""
    Create a password to protect your sensitive data.
    This password is not shared with us nor with anyone else, so please store it securely.