Improve formatting of telegram /status messages

This commit is contained in:
Matthias
2023-06-16 18:00:18 +02:00
parent 64fcb1ed11
commit 7939716a5e
+9 -9
View File
@@ -534,10 +534,10 @@ class Telegram(RPCHandler):
if order_nr == 1: if order_nr == 1:
lines.append(f"*{wording} #{order_nr}:*") lines.append(f"*{wording} #{order_nr}:*")
lines.append( lines.append(
f"*Amount:* {cur_entry_amount} " f"*Amount:* {cur_entry_amount:.8g} "
f"({round_coin_value(order['cost'], quote_currency)})" f"({round_coin_value(order['cost'], quote_currency)})"
) )
lines.append(f"*Average Price:* {cur_entry_average}") lines.append(f"*Average Price:* {cur_entry_average:.8g}")
else: else:
sum_stake = 0 sum_stake = 0
sum_amount = 0 sum_amount = 0
@@ -560,9 +560,9 @@ class Telegram(RPCHandler):
if is_open: if is_open:
lines.append("({})".format(dt_humanize(order["order_filled_date"], lines.append("({})".format(dt_humanize(order["order_filled_date"],
granularity=["day", "hour", "minute"]))) granularity=["day", "hour", "minute"])))
lines.append(f"*Amount:* {cur_entry_amount} " lines.append(f"*Amount:* {cur_entry_amount:.8g} "
f"({round_coin_value(order['cost'], quote_currency)})") f"({round_coin_value(order['cost'], quote_currency)})")
lines.append(f"*Average {wording} Price:* {cur_entry_average} " lines.append(f"*Average {wording} Price:* {cur_entry_average:.8g} "
f"({price_to_1st_entry:.2%} from 1st entry Rate)") f"({price_to_1st_entry:.2%} from 1st entry Rate)")
lines.append(f"*Order filled:* {order['order_filled_date']}") lines.append(f"*Order filled:* {order['order_filled_date']}")
@@ -633,11 +633,11 @@ class Telegram(RPCHandler):
]) ])
lines.extend([ lines.extend([
"*Open Rate:* `{open_rate:.8f}`", "*Open Rate:* `{open_rate:.8g}`",
"*Close Rate:* `{close_rate:.8f}`" if r['close_rate'] else "", "*Close Rate:* `{close_rate:.8g}`" if r['close_rate'] else "",
"*Open Date:* `{open_date}`", "*Open Date:* `{open_date}`",
"*Close Date:* `{close_date}`" if r['close_date'] else "", "*Close Date:* `{close_date}`" if r['close_date'] else "",
" \n*Current Rate:* `{current_rate:.8f}`" if r['is_open'] else "", " \n*Current Rate:* `{current_rate:.8g}`" if r['is_open'] else "",
("*Unrealized Profit:* " if r['is_open'] else "*Close Profit: *") ("*Unrealized Profit:* " if r['is_open'] else "*Close Profit: *")
+ "`{profit_ratio:.2%}` `({profit_abs_r})`", + "`{profit_ratio:.2%}` `({profit_abs_r})`",
]) ])
@@ -658,9 +658,9 @@ class Telegram(RPCHandler):
"`({initial_stop_loss_ratio:.2%})`") "`({initial_stop_loss_ratio:.2%})`")
# Adding stoploss and stoploss percentage only if it is not None # Adding stoploss and stoploss percentage only if it is not None
lines.append("*Stoploss:* `{stop_loss_abs:.8f}` " + lines.append("*Stoploss:* `{stop_loss_abs:.8g}` " +
("`({stop_loss_ratio:.2%})`" if r['stop_loss_ratio'] else "")) ("`({stop_loss_ratio:.2%})`" if r['stop_loss_ratio'] else ""))
lines.append("*Stoploss distance:* `{stoploss_current_dist:.8f}` " lines.append("*Stoploss distance:* `{stoploss_current_dist:.8g}` "
"`({stoploss_current_dist_ratio:.2%})`") "`({stoploss_current_dist_ratio:.2%})`")
if r['open_order']: if r['open_order']:
lines.append( lines.append(