adding percentage to telegram status messages

This commit is contained in:
Misagh 2019-04-01 19:13:45 +02:00
parent ecd75e43b0
commit ab579587f2
5 changed files with 18 additions and 6 deletions

View File

@ -65,16 +65,14 @@ Once all positions are sold, run `/stop` to completely stop the bot.
For each open trade, the bot will send you the following message. For each open trade, the bot will send you the following message.
> **Trade ID:** `123` > **Trade ID:** `123` `(since 1 days ago)`
> **Current Pair:** CVC/BTC > **Current Pair:** CVC/BTC
> **Open Since:** `1 days ago` > **Open Since:** `1 days ago`
> **Amount:** `26.64180098` > **Amount:** `26.64180098`
> **Open Rate:** `0.00007489` > **Open Rate:** `0.00007489`
> **Close Rate:** `None`
> **Current Rate:** `0.00007489` > **Current Rate:** `0.00007489`
> **Close Profit:** `None`
> **Current Profit:** `12.95%` > **Current Profit:** `12.95%`
> **Open Order:** `None` > **Stoploss:** `0.00007389 (-0.02%)`
### /status table ### /status table

View File

@ -111,6 +111,9 @@ class RPC(object):
close_profit=fmt_close_profit, close_profit=fmt_close_profit,
current_profit=round(current_profit * 100, 2), current_profit=round(current_profit * 100, 2),
stop_loss=trade.stop_loss, stop_loss=trade.stop_loss,
stop_loss_pct=trade.stop_loss_pct,
initial_stop_loss=trade.initial_stop_loss,
initial_stop_loss_pct=trade.initial_stop_loss_pct,
open_order='({} {} rem={:.8f})'.format( open_order='({} {} rem={:.8f})'.format(
order['type'], order['side'], order['remaining'] order['type'], order['side'], order['remaining']
) if order else None, ) if order else None,

View File

@ -197,7 +197,7 @@ class Telegram(RPC):
messages = [] messages = []
for r in results: for r in results:
lines = [ lines = [
"*Trade ID:* `{trade_id}` (since `{date}`)", "*Trade ID:* `{trade_id}` `(since {date})`",
"*Current Pair:* {pair}", "*Current Pair:* {pair}",
"*Amount:* `{amount}`", "*Amount:* `{amount}`",
"*Open Rate:* `{open_rate:.8f}`", "*Open Rate:* `{open_rate:.8f}`",
@ -205,7 +205,9 @@ class Telegram(RPC):
"*Current Rate:* `{current_rate:.8f}`", "*Current Rate:* `{current_rate:.8f}`",
"*Close Profit:* `{close_profit}`" if r['close_profit'] else "", "*Close Profit:* `{close_profit}`" if r['close_profit'] else "",
"*Current Profit:* `{current_profit:.2f}%`", "*Current Profit:* `{current_profit:.2f}%`",
"*Stoploss:* `{stop_loss:.8f}`", "*Initial Stoploss:* `{initial_stop_loss:.8f}` `({initial_stop_loss_pct}%)`"
if r['stop_loss'] != r['initial_stop_loss'] else "",
"*Stoploss:* `{stop_loss:.8f}` `({stop_loss_pct}%)`",
"*Open Order:* `{open_order}`" if r['open_order'] else "", "*Open Order:* `{open_order}`" if r['open_order'] else "",
] ]
messages.append("\n".join(filter(None, lines)).format(**r)) messages.append("\n".join(filter(None, lines)).format(**r))

View File

@ -59,6 +59,9 @@ def test_rpc_trade_status(default_conf, ticker, fee, markets, mocker) -> None:
'close_profit': None, 'close_profit': None,
'current_profit': -0.59, 'current_profit': -0.59,
'stop_loss': 0.0, 'stop_loss': 0.0,
'initial_stop_loss': 0.0,
'initial_stop_loss_pct': None,
'stop_loss_pct': None,
'open_order': '(limit buy rem=0.00000000)' 'open_order': '(limit buy rem=0.00000000)'
} == results[0] } == results[0]
@ -80,6 +83,9 @@ def test_rpc_trade_status(default_conf, ticker, fee, markets, mocker) -> None:
'close_profit': None, 'close_profit': None,
'current_profit': ANY, 'current_profit': ANY,
'stop_loss': 0.0, 'stop_loss': 0.0,
'initial_stop_loss': 0.0,
'initial_stop_loss_pct': None,
'stop_loss_pct': None,
'open_order': '(limit buy rem=0.00000000)' 'open_order': '(limit buy rem=0.00000000)'
} == results[0] } == results[0]

View File

@ -196,7 +196,10 @@ def test_status(default_conf, update, mocker, fee, ticker, markets) -> None:
'amount': 90.99181074, 'amount': 90.99181074,
'close_profit': None, 'close_profit': None,
'current_profit': -0.59, 'current_profit': -0.59,
'initial_stop_loss': 1.098e-05,
'stop_loss': 1.099e-05, 'stop_loss': 1.099e-05,
'initial_stop_loss_pct': -0.05,
'stop_loss_pct': -0.01,
'open_order': '(limit buy rem=0.00000000)' 'open_order': '(limit buy rem=0.00000000)'
}]), }]),
_status_table=status_table, _status_table=status_table,