From 0faafe3c8a4a403ef17e4db749072c2df96a6ae4 Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 10 Feb 2023 19:13:31 +0100 Subject: [PATCH] [Optimizer] fix shuffle runs on runs less than select size --- octobot/strategy_optimizer/strategy_design_optimizer.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/octobot/strategy_optimizer/strategy_design_optimizer.py b/octobot/strategy_optimizer/strategy_design_optimizer.py index b6d6800bf1..1aabe29723 100644 --- a/octobot/strategy_optimizer/strategy_design_optimizer.py +++ b/octobot/strategy_optimizer/strategy_design_optimizer.py @@ -733,7 +733,9 @@ async def _generate_and_store_backtesting_runs_schedule(self): def shuffle_and_select_runs(runs, select_size=None) -> dict: shuffled_runs = list(runs.values()) random.shuffle(shuffled_runs) - selected_runs = shuffled_runs if select_size is None else shuffled_runs[:select_size] + selected_runs = (shuffled_runs + if (select_size is None or select_size <= len(shuffled_runs)) + else shuffled_runs[:select_size]) return {i: run for i, run in enumerate(selected_runs)} def _generate_runs(self):