Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Optimizer] fix shuffle runs on runs less than select size #2223

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion octobot/strategy_optimizer/strategy_design_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The updated shuffle_and_select_runs function introduces a logic error, the if condition selects all runs when select_size is None or less than or equal to the number of runs, which means it ignores the select_size limit in cases where it should apply.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ruidazeng
oh I see, I changed it from <= to >=

return {i: run for i, run in enumerate(selected_runs)}

def _generate_runs(self):
Expand Down
Loading