From ab579587f29e3802f1c038e804214a228a4b1b26 Mon Sep 17 00:00:00 2001 From: Misagh Date: Mon, 1 Apr 2019 19:13:45 +0200 Subject: [PATCH] adding percentage to telegram status messages --- docs/telegram-usage.md | 6 ++---- freqtrade/rpc/rpc.py | 3 +++ freqtrade/rpc/telegram.py | 6 ++++-- freqtrade/tests/rpc/test_rpc.py | 6 ++++++ freqtrade/tests/rpc/test_rpc_telegram.py | 3 +++ 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/docs/telegram-usage.md b/docs/telegram-usage.md index 1ca61e54a..381a47ae9 100644 --- a/docs/telegram-usage.md +++ b/docs/telegram-usage.md @@ -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. -> **Trade ID:** `123` +> **Trade ID:** `123` `(since 1 days ago)` > **Current Pair:** CVC/BTC > **Open Since:** `1 days ago` > **Amount:** `26.64180098` > **Open Rate:** `0.00007489` -> **Close Rate:** `None` > **Current Rate:** `0.00007489` -> **Close Profit:** `None` > **Current Profit:** `12.95%` -> **Open Order:** `None` +> **Stoploss:** `0.00007389 (-0.02%)` ### /status table diff --git a/freqtrade/rpc/rpc.py b/freqtrade/rpc/rpc.py index 79db08fd3..5308c9d51 100644 --- a/freqtrade/rpc/rpc.py +++ b/freqtrade/rpc/rpc.py @@ -111,6 +111,9 @@ class RPC(object): close_profit=fmt_close_profit, current_profit=round(current_profit * 100, 2), 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( order['type'], order['side'], order['remaining'] ) if order else None, diff --git a/freqtrade/rpc/telegram.py b/freqtrade/rpc/telegram.py index 7b36e8a1f..ca9b376ec 100644 --- a/freqtrade/rpc/telegram.py +++ b/freqtrade/rpc/telegram.py @@ -197,7 +197,7 @@ class Telegram(RPC): messages = [] for r in results: lines = [ - "*Trade ID:* `{trade_id}` (since `{date}`)", + "*Trade ID:* `{trade_id}` `(since {date})`", "*Current Pair:* {pair}", "*Amount:* `{amount}`", "*Open Rate:* `{open_rate:.8f}`", @@ -205,7 +205,9 @@ class Telegram(RPC): "*Current Rate:* `{current_rate:.8f}`", "*Close Profit:* `{close_profit}`" if r['close_profit'] else "", "*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 "", ] messages.append("\n".join(filter(None, lines)).format(**r)) diff --git a/freqtrade/tests/rpc/test_rpc.py b/freqtrade/tests/rpc/test_rpc.py index 627768ec2..b454f9cd8 100644 --- a/freqtrade/tests/rpc/test_rpc.py +++ b/freqtrade/tests/rpc/test_rpc.py @@ -59,6 +59,9 @@ def test_rpc_trade_status(default_conf, ticker, fee, markets, mocker) -> None: 'close_profit': None, 'current_profit': -0.59, '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)' } == results[0] @@ -80,6 +83,9 @@ def test_rpc_trade_status(default_conf, ticker, fee, markets, mocker) -> None: 'close_profit': None, 'current_profit': ANY, '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)' } == results[0] diff --git a/freqtrade/tests/rpc/test_rpc_telegram.py b/freqtrade/tests/rpc/test_rpc_telegram.py index fb2d71d4f..b6d12fe41 100644 --- a/freqtrade/tests/rpc/test_rpc_telegram.py +++ b/freqtrade/tests/rpc/test_rpc_telegram.py @@ -196,7 +196,10 @@ def test_status(default_conf, update, mocker, fee, ticker, markets) -> None: 'amount': 90.99181074, 'close_profit': None, 'current_profit': -0.59, + 'initial_stop_loss': 1.098e-05, 'stop_loss': 1.099e-05, + 'initial_stop_loss_pct': -0.05, + 'stop_loss_pct': -0.01, 'open_order': '(limit buy rem=0.00000000)' }]), _status_table=status_table,