Use tabulate to create sell reason message.

This commit is contained in:
Xu Wang 2020-09-27 20:23:13 +01:00
parent 44ad0f631c
commit 627e221b65

View File

@ -769,16 +769,21 @@ class Telegram(RPC):
win_loss_count = {'Wins': 0, 'Losses': 0, 'Draws': 0}
win_loss_count[trade_win_loss(trade)] += 1
sell_reasons[trade['sell_reason']] = win_loss_count
sell_reason_msg = [
'| Sell Reason | Sells | Wins | Draws | Losses |',
'|-------------|------:|-----:|------:|-------:|'
]
sell_reasons_tabulate = []
# | Sell Reason | Sells | Wins | Draws | Losses |
# |-------------|------:|-----:|------:|-------:|
# | test | 1 | 2 | 3 | 4 |
for reason, count in sell_reasons.items():
msg = f'| `{reason}` | `{sum(count.values())}` | `{count['Wins']}` | `{count['Draws']}` | `{count['Losses']}` |'
sell_reason_msg.append(msg)
sell_reasons_tabulate.append([
reason, sum(count.values()),
count['Wins'],
count['Draws'],
count['Losses']
])
sell_reasons_msg = tabulate(
sell_reasons_tabulate,
headers=['Sell Reason', 'Sells', 'Wins', 'Draws', 'Losses']
)
# TODO: Duration