New /trades 3 columns and exclude open trades

This commit is contained in:
thopd88 2020-07-23 09:36:05 +07:00
parent 4c97527b04
commit 0502fe0496

View File

@ -5,6 +5,7 @@ This module manage Telegram communication
""" """
import json import json
import logging import logging
import arrow
from typing import Any, Callable, Dict from typing import Any, Callable, Dict
from tabulate import tabulate from tabulate import tabulate
@ -506,6 +507,7 @@ class Telegram(RPC):
:param update: message update :param update: message update
:return: None :return: None
""" """
stake_cur = self._config['stake_currency']
try: try:
nrecent = int(context.args[0]) nrecent = int(context.args[0])
except (TypeError, ValueError, IndexError): except (TypeError, ValueError, IndexError):
@ -515,21 +517,13 @@ class Telegram(RPC):
nrecent nrecent
) )
trades_tab = tabulate( trades_tab = tabulate(
[[trade['open_date'], [[arrow.get(trade['open_date']).humanize(),
trade['pair'], trade['pair'],
f"{trade['open_rate']}", f"{(100 * trade['close_profit']):.2f}% ({trade['close_profit_abs']})"] for trade in trades['trades'] if trade['close_profit'] is not None],
f"{trade['stake_amount']}",
trade['close_date'],
f"{trade['close_rate']}",
f"{trade['close_profit_abs']}"] for trade in trades['trades']],
headers=[ headers=[
'Open Date', 'Open Date',
'Pair', 'Pair',
'Open rate', f'Profit ({stake_cur})',
'Stake Amount',
'Close date',
'Close rate',
'Profit',
], ],
tablefmt='simple') tablefmt='simple')
message = f'<b>{nrecent} recent trades</b>:\n<pre>{trades_tab}</pre>' message = f'<b>{nrecent} recent trades</b>:\n<pre>{trades_tab}</pre>'