Refactor to use list comprehension

This commit is contained in:
Matthias 2020-12-10 07:39:50 +01:00
parent 33f330256b
commit ca99d484fc

View File

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