Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_sorted_results(results, time_frame=None):
return sorted(StrategyOptimizer.get_filtered_results(results, time_frame),
key=lambda result: result.get_average_score(), reverse=True)
def get_all_TA(config_evaluator):
return [evaluator
for evaluator, activated in config_evaluator.items()
if activated and StrategyOptimizer._is_relevant_evaluation_config(evaluator)]
def start_strategy_optimizer(config, commands):
from backtesting.strategy_optimizer.strategy_optimizer import StrategyOptimizer
optimizer = StrategyOptimizer(config, commands[0])
if optimizer.is_properly_initialized:
optimizer.find_optimal_configuration()
optimizer.print_report()
def start_optimizer(strategy, time_frames, evaluators, risks):
tools = get_bot().get_tools()
tools[BOT_TOOLS_STRATEGY_OPTIMIZER] = StrategyOptimizer(get_bot().get_config(), strategy)
optimizer = tools[BOT_TOOLS_STRATEGY_OPTIMIZER]
backtester = tools[BOT_TOOLS_BACKTESTING]
if optimizer.get_is_computing():
return False, "Optimizer already running"
elif backtester and backtester.get_is_computing():
return False, "A backtesting is already running"
else:
formatted_time_frames = TimeFrameManager.parse_time_frames(time_frames)
float_risks = [float(risk) for risk in risks]
thread = threading.Thread(target=optimizer.find_optimal_configuration, args=(evaluators,
formatted_time_frames,
float_risks))
thread.start()
return True, "Optimizer started"