How to use the octobot.api.backtesting.is_independent_backtesting_in_progress function in OctoBot

To help you get started, we’ve selected a few OctoBot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Drakkar-Software / OctoBot-Tentacles / Services / Interfaces / web_interface / models / backtesting.py View on Github external
def get_backtesting_status():
    if WebInterface.tools[BOT_TOOLS_BACKTESTING] is not None:
        independent_backtesting = WebInterface.tools[BOT_TOOLS_BACKTESTING]
        if is_independent_backtesting_in_progress(independent_backtesting):
            return "computing", get_independent_backtesting_progress(independent_backtesting) * 100
        if is_independent_backtesting_finished(independent_backtesting) or \
                is_independent_backtesting_stopped(independent_backtesting):
            return "finished", 100
        return "starting", 0
    return "not started", 0
github Drakkar-Software / OctoBot-Tentacles / Services / Interfaces / web_interface / models / backtesting.py View on Github external
def start_backtesting_using_specific_files(files, source, reset_tentacle_config=False, run_on_common_part_only=True):
    try:
        tools = WebInterface.tools
        previous_independant_backtesting = tools[BOT_TOOLS_BACKTESTING]
        if tools[BOT_TOOLS_STRATEGY_OPTIMIZER] and is_optimizer_in_progress(tools[BOT_TOOLS_STRATEGY_OPTIMIZER]):
            return False, "Optimizer already running"
        elif previous_independant_backtesting and \
                is_independent_backtesting_in_progress(previous_independant_backtesting):
            return False, "A backtesting is already running"
        else:
            if previous_independant_backtesting:
                run_in_bot_main_loop(stop_independent_backtesting(previous_independant_backtesting))
            if reset_tentacle_config:
                tentacles_setup_config = get_tentacles_setup_config()
            else:
                tentacles_setup_config = get_bot_api().get_edited_tentacles_config()
            config = get_global_config()
            independent_backtesting = create_independent_backtesting(config,
                                                                     tentacles_setup_config,
                                                                     files,
                                                                     run_on_common_part_only=run_on_common_part_only)
            run_in_bot_main_loop(initialize_and_run_independent_backtesting(independent_backtesting), blocking=False)
            tools[BOT_TOOLS_BACKTESTING] = independent_backtesting
            tools[BOT_TOOLS_BACKTESTING_SOURCE] = source
github Drakkar-Software / OctoBot-Tentacles / Services / Interfaces / web_interface / models / strategy_optimizer.py View on Github external
def start_optimizer(strategy, time_frames, evaluators, risks):
    try:
        tools = WebInterface.tools
        optimizer = tools[BOT_TOOLS_STRATEGY_OPTIMIZER]
        if optimizer is not None and is_optimizer_computing(optimizer):
            return False, "Optimizer already running"
        independent_backtesting = tools[BOT_TOOLS_BACKTESTING]
        if independent_backtesting and is_independent_backtesting_in_progress(independent_backtesting):
            return False, "A backtesting is already running"
        else:
            formatted_time_frames = parse_time_frames(time_frames)
            float_risks = [float(risk) for risk in risks]
            temp_independent_backtesting = create_independent_backtesting(get_global_config(), None, [])
            optimizer_config = run_in_bot_async_executor(
                initialize_independent_backtesting_config(temp_independent_backtesting)
            )
            optimizer = create_strategy_optimizer(optimizer_config,
                                                  get_bot_api().get_edited_tentacles_config(),
                                                  strategy)
            tools[BOT_TOOLS_STRATEGY_OPTIMIZER] = optimizer
            thread = threading.Thread(target=find_optimal_configuration,
                                      args=(optimizer, evaluators, formatted_time_frames, float_risks),
                                      name=f"{optimizer.get_name()}-WebInterface-runner")
            thread.start()