Merge pull request #1707 from mishaker/telegram_msg
Telegram status message refactoring
This commit is contained in:
@@ -110,6 +110,7 @@ class RPC(object):
|
||||
amount=round(trade.amount, 8),
|
||||
close_profit=fmt_close_profit,
|
||||
current_profit=round(current_profit * 100, 2),
|
||||
stop_loss=trade.stop_loss,
|
||||
open_order='({} {} rem={:.8f})'.format(
|
||||
order['type'], order['side'], order['remaining']
|
||||
) if order else None,
|
||||
|
@@ -194,21 +194,25 @@ class Telegram(RPC):
|
||||
for result in results:
|
||||
result['date'] = result['date'].humanize()
|
||||
|
||||
messages = [
|
||||
"*Trade ID:* `{trade_id}`\n"
|
||||
"*Current Pair:* {pair}\n"
|
||||
"*Open Since:* `{date}`\n"
|
||||
"*Amount:* `{amount}`\n"
|
||||
"*Open Rate:* `{open_rate:.8f}`\n"
|
||||
"*Close Rate:* `{close_rate}`\n"
|
||||
"*Current Rate:* `{current_rate:.8f}`\n"
|
||||
"*Close Profit:* `{close_profit}`\n"
|
||||
"*Current Profit:* `{current_profit:.2f}%`\n"
|
||||
"*Open Order:* `{open_order}`".format(**result)
|
||||
for result in results
|
||||
]
|
||||
messages = []
|
||||
for r in results:
|
||||
lines = [
|
||||
"*Trade ID:* `{trade_id}` (since `{date}`)",
|
||||
"*Current Pair:* {pair}",
|
||||
"*Amount:* `{amount}`",
|
||||
"*Open Rate:* `{open_rate:.8f}`",
|
||||
"*Close Rate:* `{close_rate}`" if r['close_rate'] else "",
|
||||
"*Current Rate:* `{current_rate:.8f}`",
|
||||
"*Close Profit:* `{close_profit}`" if r['close_profit'] else "",
|
||||
"*Current Profit:* `{current_profit:.2f}%`",
|
||||
"*Stoploss:* `{stop_loss:.8f}`",
|
||||
"*Open Order:* `{open_order}`" if r['open_order'] else "",
|
||||
]
|
||||
messages.append("\n".join(filter(None, lines)).format(**r))
|
||||
|
||||
for msg in messages:
|
||||
self._send_msg(msg, bot=bot)
|
||||
|
||||
except RPCException as e:
|
||||
self._send_msg(str(e), bot=bot)
|
||||
|
||||
|
Reference in New Issue
Block a user