Show winning vs. losing trades

This commit is contained in:
Matthias 2020-06-24 06:43:19 +02:00
parent 112906458f
commit 0509b9a8fc
3 changed files with 13 additions and 1 deletions

View File

@ -269,6 +269,8 @@ class RPC:
profit_closed_coin = []
profit_closed_ratio = []
durations = []
winning_trades = 0
losing_trades = 0
for trade in trades:
current_rate: float = 0.0
@ -282,6 +284,10 @@ class RPC:
profit_ratio = trade.close_profit
profit_closed_coin.append(trade.close_profit_abs)
profit_closed_ratio.append(profit_ratio)
if trade.close_profit > 0:
winning_trades += 1
else:
losing_trades += 1
else:
# Get current rate
try:
@ -344,6 +350,8 @@ class RPC:
'avg_duration': str(timedelta(seconds=sum(durations) / num)).split('.')[0],
'best_pair': best_pair[0] if best_pair else '',
'best_rate': round(best_pair[1] * 100, 2) if best_pair else 0,
'winning_trades': winning_trades,
'losing_trades': losing_trades,
}
def _rpc_balance(self, stake_currency: str, fiat_display_currency: str) -> Dict:

View File

@ -366,7 +366,9 @@ class Telegram(RPC):
f"∙ `{profit_all_fiat:.3f} {fiat_disp_cur}`\n"
f"*Total Trade Count:* `{trade_count}`\n"
f"*First Trade opened:* `{first_trade_date}`\n"
f"*Latest Trade opened:* `{latest_trade_date}`")
f"*Latest Trade opened:* `{latest_trade_date}\n`"
f"*Win / Loss:* `{stats['winning_trades']} / {stats['losing_trades']}`"
)
if stats['closed_trade_count'] > 0:
markdown_msg += (f"\n*Avg. Duration:* `{avg_duration}`\n"
f"*Best Performing:* `{best_pair}: {best_rate:.2f}%`")

View File

@ -444,6 +444,8 @@ def test_api_profit(botclient, mocker, ticker, fee, markets, limit_buy_order, li
'profit_closed_percent_sum': 6.2,
'trade_count': 1,
'closed_trade_count': 1,
'winning_trades': 1,
'losing_trades': 0,
}