def list(params):
        """
        List all mod configuration
        """
        from colorama import init, Fore
        from tabulate import tabulate
        from rqalpha.utils.config import get_mod_conf
        init()

        mod_config = get_mod_conf()
        table = []

        for mod_name, mod in six.iteritems(mod_config['mod']):
            table.append([
                Fore.RESET + mod_name,
                (Fore.GREEN + "enabled" if mod['enabled'] else Fore.RED +
                 "disabled") + Fore.RESET
            ])

        headers = [Fore.CYAN + "name", Fore.CYAN + "status" + Fore.RESET]

        six.print_(tabulate(table, headers=headers, tablefmt="psql"))
        six.print_(
            Fore.LIGHTYELLOW_EX +
            "You can use `rqalpha mod list/install/uninstall/enable/disable` to manage your mods"
        )
Beispiel #2
0
    def list(params):
        """
        List all mod configuration
        """
        from colorama import init, Fore
        from tabulate import tabulate
        from rqalpha.utils.config import get_mod_conf
        init()

        mod_config = get_mod_conf()
        table = []

        for mod_name, mod in six.iteritems(mod_config['mod']):
            table.append([
                Fore.RESET + mod_name,
                (Fore.GREEN + "enabled" if mod['enabled'] else Fore.RED + "disabled") + Fore.RESET
            ])

        headers = [
            Fore.CYAN + "name",
            Fore.CYAN + "status" + Fore.RESET
        ]

        six.print_(tabulate(table, headers=headers, tablefmt="psql"))
        six.print_(Fore.LIGHTYELLOW_EX + "You can use `rqalpha mod list/install/uninstall/enable/disable` to manage your mods")
Beispiel #3
0
def inject_mod_commands():
    """
    获取配置,注册模块
    :return:
    """
    from rqalpha.utils.config import get_mod_conf
    from rqalpha.mod import SYSTEM_MOD_LIST
    from rqalpha.utils.package_helper import import_mod
    # 获取配置
    mod_config = get_mod_conf()

    # 加载配置中的模块
    for mod_name, config in six.iteritems(mod_config['mod']):
        if 'lib' in config:
            lib_name = config["lib"]
        else:
            lib_name = "rqalpha_mod_{}".format(mod_name)
        if not config['enabled']:
            continue
        try:
            if mod_name in SYSTEM_MOD_LIST:
                # inject system mod
                import_mod("rqalpha.mod." + lib_name)
            else:
                # inject third part mod
                import_mod(lib_name)
        except Exception as e:
            pass
Beispiel #4
0
def server():
    modules = None
    mod_config = get_mod_conf()
    res = "# rqalpha param list \n"
    for mod_name, mod in six.iteritems(mod_config['mod']):
        if not mod_name.startswith("sys_"):
            modules = import_module("rqalpha_mod_" + mod_name)
    if modules is not None:
        for k, v in modules.cli.commands.items():
            info = get_info(v.params)
            if len(info) > 0:
                help_str = v.help.replace("\n\n", "\n").replace("\n", "\n> ")
                res += "### {}\n> {}\n{}---\n\n".format(v.name, help_str, info)
    print(res)
    return save_to_file(res, "rqalpha_param_list", add_time=True)
Beispiel #5
0
    def list(params):
        """
        List all mod configuration
        """
        from tabulate import tabulate
        from rqalpha.utils.config import get_mod_conf

        mod_config = get_mod_conf()
        table = []

        for mod_name, mod in six.iteritems(mod_config['mod']):
            table.append(
                [mod_name, ("enabled" if mod['enabled'] else "disabled")])

        headers = ["name", "status"]

        six.print_(tabulate(table, headers=headers, tablefmt="psql"))
        six.print_(
            "You can use `rqalpha mod list/install/uninstall/enable/disable` to manage your mods"
        )
Beispiel #6
0
def inject_mod_commands():
    from rqalpha.utils.config import get_mod_conf
    from rqalpha.mod import SYSTEM_MOD_LIST
    from rqalpha.utils.package_helper import import_mod
    mod_config = get_mod_conf()

    for mod_name, config in six.iteritems(mod_config['mod']):
        if 'lib' in config:
            lib_name = config["lib"]
        else:
            lib_name = "rqalpha_mod_{}".format(mod_name)
        if not config['enabled']:
            continue
        try:
            if mod_name in SYSTEM_MOD_LIST:
                # inject system mod
                import_mod("rqalpha.mod." + lib_name)
            else:
                # inject third part mod
                import_mod(lib_name)
        except Exception as e:
            pass