Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def convert_result_into_dict(index, evaluators, time_frames, risk, score, trades):
return {
TestSuiteResult.INDEX: index,
TestSuiteResult.EVALUATORS: evaluators,
TestSuiteResult.TIME_FRAMES: time_frames,
TestSuiteResult.RISK: risk,
TestSuiteResult.SCORE: score,
TestSuiteResult.AVERAGE_TRADES: trades,
}
def convert_result_into_dict(index, evaluators, time_frames, risk, score, trades):
return {
TestSuiteResult.INDEX: index,
TestSuiteResult.EVALUATORS: evaluators,
TestSuiteResult.TIME_FRAMES: time_frames,
TestSuiteResult.RISK: risk,
TestSuiteResult.SCORE: score,
TestSuiteResult.AVERAGE_TRADES: trades,
}
def convert_result_into_dict(index, evaluators, time_frames, risk, score, trades):
return {
TestSuiteResult.INDEX: index,
TestSuiteResult.EVALUATORS: evaluators,
TestSuiteResult.TIME_FRAMES: time_frames,
TestSuiteResult.RISK: risk,
TestSuiteResult.SCORE: score,
TestSuiteResult.AVERAGE_TRADES: trades,
}
def convert_result_into_dict(index, evaluators, time_frames, risk, score, trades):
return {
TestSuiteResult.INDEX: index,
TestSuiteResult.EVALUATORS: evaluators,
TestSuiteResult.TIME_FRAMES: time_frames,
TestSuiteResult.RISK: risk,
TestSuiteResult.SCORE: score,
TestSuiteResult.AVERAGE_TRADES: trades,
}
def convert_result_into_dict(index, evaluators, time_frames, risk, score, trades):
return {
TestSuiteResult.INDEX: index,
TestSuiteResult.EVALUATORS: evaluators,
TestSuiteResult.TIME_FRAMES: time_frames,
TestSuiteResult.RISK: risk,
TestSuiteResult.SCORE: score,
TestSuiteResult.AVERAGE_TRADES: trades,
}
def convert_result_into_dict(index, evaluators, time_frames, risk, score, trades):
return {
TestSuiteResult.INDEX: index,
TestSuiteResult.EVALUATORS: evaluators,
TestSuiteResult.TIME_FRAMES: time_frames,
TestSuiteResult.RISK: risk,
TestSuiteResult.SCORE: score,
TestSuiteResult.AVERAGE_TRADES: trades,
}
def create_backtesting_bot(config):
bot = OctoBot(config)
return bot
def test_create_bot():
# launch a bot
config = load_test_config()
bot = OctoBot(config)
bot.stop_threads()
def test_run_bot():
# launch a bot
config = load_test_config()
bot = OctoBot(config)
bot.time_frames = [TimeFrames.ONE_MINUTE]
bot.create_exchange_traders()
bot.create_evaluation_threads()
bot.start_threads()
# let it run 2 minutes: test will fail if an exception is raised
# 1.9 to stop threads before the next time frame
time.sleep(1.9 * 60)
# stop the bot
bot.stop_threads()
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
return True, "Backtesting started"
except Exception as e:
LOGGER.exception(e)
return False, f"Error when starting backtesting: {e}"