From 5c0f5588a6a87c0ff92f9618f19ab4f6e73a2186 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 8 Jul 2023 09:49:01 +0200 Subject: [PATCH] Simplify sort_values in PerformanceFilter Avoids potential regression in numpy 1.25.0 - which doesn't keep prior sort order in chained sort_values calls. --- freqtrade/plugins/pairlist/PerformanceFilter.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/freqtrade/plugins/pairlist/PerformanceFilter.py b/freqtrade/plugins/pairlist/PerformanceFilter.py index 06c504317..b45259605 100644 --- a/freqtrade/plugins/pairlist/PerformanceFilter.py +++ b/freqtrade/plugins/pairlist/PerformanceFilter.py @@ -89,10 +89,10 @@ class PerformanceFilter(IPairList): # Sort the list using: # - primarily performance (high to low) # - then count (low to high, so as to favor same performance with fewer trades) - # - then pair name alphametically + # - then by prior index, keeping original sorting order sorted_df = list_df.merge(performance, on='pair', how='left')\ - .fillna(0).sort_values(by=['count', 'prior_idx'], ascending=True)\ - .sort_values(by=['profit_ratio'], ascending=False) + .fillna(0).sort_values(by=['profit_ratio', 'count', 'prior_idx'], + ascending=[False, True, True]) if self._min_profit is not None: removed = sorted_df[sorted_df['profit_ratio'] < self._min_profit] for _, row in removed.iterrows():