From 3398469e555d6f913088a5d550035567243efbe0 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 12 Dec 2021 13:21:24 +0100 Subject: [PATCH] Update PerformanceFilter to have min_profit as ratio again. closes #6056 --- docs/includes/pairlists.md | 4 ++-- .../plugins/pairlist/PerformanceFilter.py | 8 +++---- tests/plugins/test_pairlist.py | 23 ++++++++++--------- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/docs/includes/pairlists.md b/docs/includes/pairlists.md index f6e8cb6d4..031397719 100644 --- a/docs/includes/pairlists.md +++ b/docs/includes/pairlists.md @@ -196,7 +196,7 @@ Trade count is used as a tie breaker. You can use the `minutes` parameter to only consider performance of the past X minutes (rolling window). Not defining this parameter (or setting it to 0) will use all-time performance. -The optional `min_profit` parameter defines the minimum profit a pair must have to be considered. +The optional `min_profit` (as ratio -> a setting of `0.01` corresponds to 1%) parameter defines the minimum profit a pair must have to be considered. Pairs below this level will be filtered out. Using this parameter without `minutes` is highly discouraged, as it can lead to an empty pairlist without a way to recover. @@ -206,7 +206,7 @@ Using this parameter without `minutes` is highly discouraged, as it can lead to { "method": "PerformanceFilter", "minutes": 1440, // rolling 24h - "min_profit": 0.01 + "min_profit": 0.01 // minimal profit 1% } ], ``` diff --git a/freqtrade/plugins/pairlist/PerformanceFilter.py b/freqtrade/plugins/pairlist/PerformanceFilter.py index 671b6362b..d3196d3ae 100644 --- a/freqtrade/plugins/pairlist/PerformanceFilter.py +++ b/freqtrade/plugins/pairlist/PerformanceFilter.py @@ -68,14 +68,14 @@ class PerformanceFilter(IPairList): # - then pair name alphametically sorted_df = list_df.merge(performance, on='pair', how='left')\ .fillna(0).sort_values(by=['count', 'pair'], ascending=True)\ - .sort_values(by=['profit'], ascending=False) + .sort_values(by=['profit_ratio'], ascending=False) if self._min_profit is not None: - removed = sorted_df[sorted_df['profit'] < self._min_profit] + removed = sorted_df[sorted_df['profit_ratio'] < self._min_profit] for _, row in removed.iterrows(): self.log_once( - f"Removing pair {row['pair']} since {row['profit']} is " + f"Removing pair {row['pair']} since {row['profit_ratio']} is " f"below {self._min_profit}", logger.info) - sorted_df = sorted_df[sorted_df['profit'] >= self._min_profit] + sorted_df = sorted_df[sorted_df['profit_ratio'] >= self._min_profit] pairlist = sorted_df['pair'].tolist() diff --git a/tests/plugins/test_pairlist.py b/tests/plugins/test_pairlist.py index 0d0e43b0b..b85484a60 100644 --- a/tests/plugins/test_pairlist.py +++ b/tests/plugins/test_pairlist.py @@ -1106,33 +1106,34 @@ def test_pairlistmanager_no_pairlist(mocker, whitelist_conf): # Happy path: Descending order, all values filled ([{"method": "StaticPairList"}, {"method": "PerformanceFilter"}], ['ETH/BTC', 'TKN/BTC'], - [{'pair': 'TKN/BTC', 'profit': 5, 'count': 3}, {'pair': 'ETH/BTC', 'profit': 4, 'count': 2}], + [{'pair': 'TKN/BTC', 'profit_ratio': 0.05, 'count': 3}, + {'pair': 'ETH/BTC', 'profit_ratio': 0.04, 'count': 2}], ['TKN/BTC', 'ETH/BTC']), # Performance data outside allow list ignored ([{"method": "StaticPairList"}, {"method": "PerformanceFilter"}], ['ETH/BTC', 'TKN/BTC'], - [{'pair': 'OTHER/BTC', 'profit': 5, 'count': 3}, - {'pair': 'ETH/BTC', 'profit': 4, 'count': 2}], + [{'pair': 'OTHER/BTC', 'profit_ratio': 0.05, 'count': 3}, + {'pair': 'ETH/BTC', 'profit_ratio': 0.04, 'count': 2}], ['ETH/BTC', 'TKN/BTC']), # Partial performance data missing and sorted between positive and negative profit ([{"method": "StaticPairList"}, {"method": "PerformanceFilter"}], ['ETH/BTC', 'TKN/BTC', 'LTC/BTC'], - [{'pair': 'ETH/BTC', 'profit': -5, 'count': 100}, - {'pair': 'TKN/BTC', 'profit': 4, 'count': 2}], + [{'pair': 'ETH/BTC', 'profit_ratio': -0.05, 'count': 100}, + {'pair': 'TKN/BTC', 'profit_ratio': 0.04, 'count': 2}], ['TKN/BTC', 'LTC/BTC', 'ETH/BTC']), # Tie in performance data broken by count (ascending) ([{"method": "StaticPairList"}, {"method": "PerformanceFilter"}], ['ETH/BTC', 'TKN/BTC', 'LTC/BTC'], - [{'pair': 'LTC/BTC', 'profit': -5.01, 'count': 101}, - {'pair': 'TKN/BTC', 'profit': -5.01, 'count': 2}, - {'pair': 'ETH/BTC', 'profit': -5.01, 'count': 100}], + [{'pair': 'LTC/BTC', 'profit_ratio': -0.0501, 'count': 101}, + {'pair': 'TKN/BTC', 'profit_ratio': -0.0501, 'count': 2}, + {'pair': 'ETH/BTC', 'profit_ratio': -0.0501, 'count': 100}], ['TKN/BTC', 'ETH/BTC', 'LTC/BTC']), # Tie in performance and count, broken by alphabetical sort ([{"method": "StaticPairList"}, {"method": "PerformanceFilter"}], ['ETH/BTC', 'TKN/BTC', 'LTC/BTC'], - [{'pair': 'LTC/BTC', 'profit': -5.01, 'count': 1}, - {'pair': 'TKN/BTC', 'profit': -5.01, 'count': 1}, - {'pair': 'ETH/BTC', 'profit': -5.01, 'count': 1}], + [{'pair': 'LTC/BTC', 'profit_ratio': -0.0501, 'count': 1}, + {'pair': 'TKN/BTC', 'profit_ratio': -0.0501, 'count': 1}, + {'pair': 'ETH/BTC', 'profit_ratio': -0.0501, 'count': 1}], ['ETH/BTC', 'LTC/BTC', 'TKN/BTC']), ]) def test_performance_filter(mocker, whitelist_conf, pairlists, pair_allowlist, overall_performance,