Refactor to use list comprehension

This commit is contained in:
Matthias 2020-12-10 07:39:50 +01:00
parent 33f330256b
commit ca99d484fc
1 changed files with 4 additions and 4 deletions

View File

@ -398,7 +398,6 @@ class Telegram(RPC):
"""
stats = self._rpc_stats()
sell_reasons_tabulate = []
reason_map = {
'roi': 'ROI',
'stop_loss': 'Stoploss',
@ -408,13 +407,14 @@ class Telegram(RPC):
'force_sell': 'Forcesell',
'emergency_sell': 'Emergency Sell',
}
for reason, count in stats['sell_reasons'].items():
sell_reasons_tabulate.append([
sell_reasons_tabulate = [
[
reason_map.get(reason, reason),
sum(count.values()),
count['wins'],
count['losses']
])
] for reason, count in stats['sell_reasons'].items()
]
sell_reasons_msg = tabulate(
sell_reasons_tabulate,
headers=['Sell Reason', 'Sells', 'Wins', 'Losses']