Merge pull request #5210 from eschava/profit_best_pair

"/profit N" command should print best pair for the same period of time, not for all trades
This commit is contained in:
Matthias 2021-06-29 06:39:46 +02:00 committed by GitHub
commit eb5cee4934
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -841,7 +841,7 @@ class Trade(_DECL_BASE, LocalTrade):
] ]
@staticmethod @staticmethod
def get_best_pair(): def get_best_pair(start_date: datetime = datetime.fromtimestamp(0)):
""" """
Get best pair with closed trade. Get best pair with closed trade.
NOTE: Not supported in Backtesting. NOTE: Not supported in Backtesting.
@ -849,7 +849,7 @@ class Trade(_DECL_BASE, LocalTrade):
""" """
best_pair = Trade.query.with_entities( best_pair = Trade.query.with_entities(
Trade.pair, func.sum(Trade.close_profit).label('profit_sum') 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) \ .group_by(Trade.pair) \
.order_by(desc('profit_sum')).first() .order_by(desc('profit_sum')).first()
return best_pair return best_pair

View File

@ -381,7 +381,7 @@ class RPC:
) )
profit_all_ratio.append(profit_ratio) profit_all_ratio.append(profit_ratio)
best_pair = Trade.get_best_pair() best_pair = Trade.get_best_pair(start_date)
# Prepare data to display # Prepare data to display
profit_closed_coin_sum = round(sum(profit_closed_coin), 8) profit_closed_coin_sum = round(sum(profit_closed_coin), 8)