Ejemplo n.º 1
0
async def main():
    await create_yml_files()

    # This init_logging() call is important, to skip over the missing config warnings.
    init_logging("hummingbot_logs.yml")

    read_system_configs_from_yml()

    hb = HummingbotApplication.main_application()

    with patch_stdout(log_field=hb.app.log_field):
        dev_mode = check_dev_mode()
        if dev_mode:
            hb.app.log("Running from dev branches. Full remote logging will be enabled.")
        init_logging("hummingbot_logs.yml",
                     override_log_level=global_config_map.get("log_level").value,
                     dev_mode=dev_mode)
        tasks: List[Coroutine] = [hb.run()]
        if global_config_map.get("debug_console").value:
            if not hasattr(__builtins__, "help"):
                import _sitebuiltins
                __builtins__.help = _sitebuiltins._Helper()

            from hummingbot.core.management.console import start_management_console
            management_port: int = detect_available_port(8211)
            tasks.append(start_management_console(locals(), host="localhost", port=management_port))
        await safe_gather(*tasks)
Ejemplo n.º 2
0
async def main():
    chdir_to_data_directory()

    await create_yml_files()

    # This init_logging() call is important, to skip over the missing config warnings.
    init_logging("hummingbot_logs.yml")
    hb = HummingbotApplication.main_application()
    setHummingInstance(hb)

    read_configs_from_yml()
    ExchangeRateConversion.get_instance().start()

    with patch_stdout(log_field=hb.app.log_field):
        dev_mode = check_dev_mode()
        if dev_mode:
            hb.app.log(
                "Running from dev branches. Full remote logging will be enabled."
            )
        init_logging(
            "hummingbot_logs.yml",
            override_log_level=global_config_map.get("log_level").value,
            dev_mode=dev_mode)
        tasks: List[Coroutine] = [hb.run(), sio.connect('ws://localhost:5000')]
        await safe_gather(*tasks)
Ejemplo n.º 3
0
async def quick_start(args):
    config_file_name = args.config_file_name
    wallet = args.wallet
    password = args.config_password

    if args.auto_set_permissions is not None:
        autofix_permissions(args.auto_set_permissions)

    if password is not None and not Security.login(password):
        logging.getLogger().error("Invalid password.")
        return

    await Security.wait_til_decryption_done()
    await create_yml_files()
    init_logging("hummingbot_logs.yml")
    read_system_configs_from_yml()

    hb = HummingbotApplication.main_application()
    # Todo: validate strategy and config_file_name before assinging

    if config_file_name is not None:
        hb.strategy_file_name = config_file_name
        hb.strategy_name = update_strategy_config_map_from_file(
            os.path.join(CONF_FILE_PATH, config_file_name))

    # To ensure quickstart runs with the default value of False for kill_switch_enabled if not present
    if not global_config_map.get("kill_switch_enabled"):
        global_config_map.get("kill_switch_enabled").value = False

    if wallet and password:
        global_config_map.get("ethereum_wallet").value = wallet

    if hb.strategy_name and hb.strategy_file_name:
        if not all_configs_complete(hb.strategy_name):
            hb.status()

    with patch_stdout(log_field=hb.app.log_field):
        dev_mode = check_dev_mode()
        if dev_mode:
            hb.app.log(
                "Running from dev branches. Full remote logging will be enabled."
            )

        log_level = global_config_map.get("log_level").value
        init_logging("hummingbot_logs.yml",
                     override_log_level=log_level,
                     dev_mode=dev_mode)

        if hb.strategy_file_name is not None and hb.strategy_name is not None:
            await write_config_to_yml(hb.strategy_name, hb.strategy_file_name)
            hb.start(log_level)

        tasks: List[Coroutine] = [hb.run()]
        if global_config_map.get("debug_console").value:
            management_port: int = detect_available_port(8211)
            tasks.append(
                start_management_console(locals(),
                                         host="localhost",
                                         port=management_port))
        await safe_gather(*tasks)
Ejemplo n.º 4
0
async def main():
    await create_yml_files()

    # This init_logging() call is important, to skip over the missing config warnings.
    init_logging("hummingbot_logs.yml")

    read_configs_from_yml()

    if __name__ == '__main__':
        hb = HummingbotApplication.main_application()
    with patch_stdout(log_field=hb.app.log_field):
        dev_mode = check_dev_mode()
        if dev_mode:
            hb.app.log(
                "Running from dev branches. Full remote logging will be enabled."
            )
        init_logging(
            "hummingbot_logs.yml",
            override_log_level=global_config_map.get("log_level").value,
            dev_mode=dev_mode)
        tasks: List[Coroutine] = [hb.run()]
        if global_config_map.get("debug_console").value:
            management_port: int = detect_available_port(8211)
            tasks.append(
                start_management_console(locals(),
                                         host="localhost",
                                         port=management_port))
        await asyncio.gather(*tasks)
async def quick_start():
    try:
        args = CmdlineParser().parse_args()

        strategy = args.strategy
        config_file_name = args.config_file_name
        wallet = args.wallet
        password = args.config_password

        await create_yml_files()
        init_logging("hummingbot_logs.yml")
        read_configs_from_yml()
        ExchangeRateConversion.get_instance().start()
        await ExchangeRateConversion.get_instance().wait_till_ready()
        hb = HummingbotApplication.main_application()

        in_memory_config_map.get("password").value = password
        in_memory_config_map.get("strategy").value = strategy
        in_memory_config_map.get("strategy").validate(strategy)
        in_memory_config_map.get("strategy_file_path").value = config_file_name
        in_memory_config_map.get("strategy_file_path").validate(config_file_name)

        # To ensure quickstart runs with the default value of False for kill_switch_enabled if not present
        if not global_config_map.get("kill_switch_enabled"):
            global_config_map.get("kill_switch_enabled").value = False

        if wallet and password:
            global_config_map.get("wallet").value = wallet
            hb.acct = unlock_wallet(public_key=wallet, password=password)

        if not hb.config_complete:
            config_map = load_required_configs()
            empty_configs = [key for key, config in config_map.items() if config.value is None and config.required]
            empty_config_description: str = "\n- ".join([""] + empty_configs)
            raise ValueError(f"Missing empty configs: {empty_config_description}\n")

        with patch_stdout(log_field=hb.app.log_field):
            dev_mode = check_dev_mode()
            if dev_mode:
                hb.app.log("Running from dev branches. Full remote logging will be enabled.")

            log_level = global_config_map.get("log_level").value
            init_logging("hummingbot_logs.yml",
                         override_log_level=log_level,
                         dev_mode=dev_mode,
                         strategy_file_path=config_file_name)
            await write_config_to_yml()
            hb.start(log_level)

            tasks: List[Coroutine] = [hb.run()]
            if global_config_map.get("debug_console").value:
                management_port: int = detect_available_port(8211)
                tasks.append(start_management_console(locals(), host="localhost", port=management_port))
            await safe_gather(*tasks)

    except Exception as e:
        # In case of quick start failure, start the bot normally to allow further configuration
        logging.getLogger().warning(f"Bot config incomplete: {str(e)}. Starting normally...")
        await normal_start()
Ejemplo n.º 6
0
    def did_start_ui(self):
        self._stdout_redirect_context.enter_context(
            patch_stdout(log_field=self.log_field))

        log_level = global_config_map.get("log_level").value
        init_logging("hummingbot_logs.yml", override_log_level=log_level)

        self.trigger_event(HummingbotUIEvent.Start, self)
async def quick_start():
    try:
        args = CmdlineParser().parse_args()

        strategy = args.strategy
        config_file_name = args.config_file_name
        wallet = args.wallet
        wallet_password = args.wallet_password

        await create_yml_files()
        init_logging("hummingbot_logs.yml")
        read_configs_from_yml()
        hb = HummingbotApplication.main_application()

        in_memory_config_map.get("strategy").value = strategy
        in_memory_config_map.get("strategy").validate(strategy)
        in_memory_config_map.get("strategy_file_path").value = config_file_name
        in_memory_config_map.get("strategy_file_path").validate(
            config_file_name)

        if wallet and wallet_password:
            global_config_map.get("wallet").value = wallet
            hb.acct = unlock_wallet(public_key=wallet,
                                    password=wallet_password)

        if not hb.config_complete:
            empty_configs = hb._get_empty_configs()
            empty_config_description: str = "\n- ".join([""] + empty_configs)
            raise ValueError(
                f"Missing empty configs: {empty_config_description}\n")

        with patch_stdout(log_field=hb.app.log_field):
            dev_mode = check_dev_mode()
            if dev_mode:
                hb.app.log(
                    "Running from dev branches. Full remote logging will be enabled."
                )

            log_level = global_config_map.get("log_level").value
            init_logging("hummingbot_logs.yml",
                         override_log_level=log_level,
                         dev_mode=dev_mode)
            hb.start(log_level)

            tasks: List[Coroutine] = [hb.run()]
            if global_config_map.get("debug_console").value:
                management_port: int = detect_available_port(8211)
                tasks.append(
                    start_management_console(locals(),
                                             host="localhost",
                                             port=management_port))
            await asyncio.gather(*tasks)

    except Exception as e:
        # In case of quick start failure, start the bot normally to allow further configuration
        logging.getLogger().warning(
            f"Bot config incomplete: {str(e)}. Starting normally...")
        await normal_start()
Ejemplo n.º 8
0
async def main():
    await create_yml_files()
    init_logging("hummingbot_logs.yml")
    read_configs_from_yml()
    hb = HummingbotApplication.main_application()
    hb.acct = unlock_wallet(public_key=WALLET_PUBLIC_KEY, password=WALLET_PASSWORD)

    with patch_stdout(log_field=hb.app.log_field):
        init_logging("hummingbot_logs.yml", override_log_level=global_config_map.get("log_level").value)
        logging.getLogger().info("____DEV_MODE__start_directly__")

        in_memory_config_map.get("strategy").value = STRATEGY
        in_memory_config_map.get("strategy").validate(STRATEGY)
        in_memory_config_map.get("strategy_file_path").value = STRATEGY_PATH
        in_memory_config_map.get("strategy_file_path").validate(STRATEGY_PATH)
        global_config_map.get("wallet").value = WALLET_PUBLIC_KEY

        tasks: List[Coroutine] = [hb.run()]
        await asyncio.gather(*tasks)