From d54de724719fde6156dc692cea986a12ff4b39f2 Mon Sep 17 00:00:00 2001 From: Eugene Schava Date: Mon, 28 Jun 2021 23:42:09 +0300 Subject: [PATCH] "/profit N" command should print best pair for the same period of time, not for all trades --- freqtrade/persistence/models.py | 4 ++-- freqtrade/rpc/rpc.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/freqtrade/persistence/models.py b/freqtrade/persistence/models.py index bbbc55c13..b4c299120 100644 --- a/freqtrade/persistence/models.py +++ b/freqtrade/persistence/models.py @@ -841,7 +841,7 @@ class Trade(_DECL_BASE, LocalTrade): ] @staticmethod - def get_best_pair(): + def get_best_pair(start_date: datetime = datetime.fromtimestamp(0)): """ Get best pair with closed trade. NOTE: Not supported in Backtesting. @@ -849,7 +849,7 @@ class Trade(_DECL_BASE, LocalTrade): """ best_pair = Trade.query.with_entities( Trade.pair, func.sum(Trade.close_profit).label('profit_sum') - ).filter(Trade.is_open.is_(False)) \ + ).filter(Trade.is_open.is_(False) & (Trade.close_date >= start_date)) \ .group_by(Trade.pair) \ .order_by(desc('profit_sum')).first() return best_pair diff --git a/freqtrade/rpc/rpc.py b/freqtrade/rpc/rpc.py index 1b94bc11f..538e95f40 100644 --- a/freqtrade/rpc/rpc.py +++ b/freqtrade/rpc/rpc.py @@ -381,7 +381,7 @@ class RPC: ) profit_all_ratio.append(profit_ratio) - best_pair = Trade.get_best_pair() + best_pair = Trade.get_best_pair(start_date) # Prepare data to display profit_closed_coin_sum = round(sum(profit_closed_coin), 8)