Performancefilter - improve sorting

Ordering of Pairs without history should remain identical, so pairs with
positive performance move to the front, and negative pairs move to the back.

closes #4893
This commit is contained in:
Matthias
2022-02-06 16:19:11 +01:00
parent ef086d438c
commit 5eb5029856
3 changed files with 33 additions and 4 deletions

View File

@@ -60,6 +60,7 @@ class PerformanceFilter(IPairList):
# Get pairlist from performance dataframe values
list_df = pd.DataFrame({'pair': pairlist})
list_df['prior_idx'] = list_df.index
# Set initial value for pairs with no trades to 0
# Sort the list using:
@@ -67,7 +68,7 @@ class PerformanceFilter(IPairList):
# - then count (low to high, so as to favor same performance with fewer trades)
# - then pair name alphametically
sorted_df = list_df.merge(performance, on='pair', how='left')\
.fillna(0).sort_values(by=['count', 'pair'], ascending=True)\
.fillna(0).sort_values(by=['count', 'prior_idx'], ascending=True)\
.sort_values(by=['profit_ratio'], ascending=False)
if self._min_profit is not None:
removed = sorted_df[sorted_df['profit_ratio'] < self._min_profit]