"/profit N" command should print best pair for the same period of time, not for all trades

This commit is contained in:
Eugene Schava 2021-06-28 23:42:09 +03:00
parent 65d7e74888
commit d54de72471
2 changed files with 3 additions and 3 deletions

View File

@ -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

View File

@ -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)