From 33e9ed5a5ee8290813d19e9bc7a3d54d6958f9c7 Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 4 Dec 2018 19:58:26 +0100 Subject: [PATCH] Print sellreason in sell-message --- docs/webhook-config.md | 1 + freqtrade/freqtradebot.py | 1 + freqtrade/rpc/telegram.py | 23 ++++++++++++----------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/docs/webhook-config.md b/docs/webhook-config.md index 71524187a..e5509d6c9 100644 --- a/docs/webhook-config.md +++ b/docs/webhook-config.md @@ -66,6 +66,7 @@ Possible parameters are: * profit_fiat * stake_currency * fiat_currency +* sell_reason ### Webhookstatus diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index a73a2e98f..53c012a17 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -834,6 +834,7 @@ class FreqtradeBot(object): 'current_rate': current_rate, 'profit_amount': profit_trade, 'profit_percent': profit_percent, + 'sell_reason': sell_reason.value } # For regular case, when the configuration exists diff --git a/freqtrade/rpc/telegram.py b/freqtrade/rpc/telegram.py index 55c5abef2..032593e9e 100644 --- a/freqtrade/rpc/telegram.py +++ b/freqtrade/rpc/telegram.py @@ -125,9 +125,9 @@ class Telegram(RPC): else: msg['stake_amount_fiat'] = 0 - message = "*{exchange}:* Buying [{pair}]({market_url})\n" \ - "with limit `{limit:.8f}\n" \ - "({stake_amount:.6f} {stake_currency}".format(**msg) + message = ("*{exchange}:* Buying [{pair}]({market_url})\n" + "with limit `{limit:.8f}\n" + "({stake_amount:.6f} {stake_currency}").format(**msg) if msg.get('fiat_currency', None): message += ",{stake_amount_fiat:.3f} {fiat_currency}".format(**msg) @@ -137,12 +137,13 @@ class Telegram(RPC): msg['amount'] = round(msg['amount'], 8) msg['profit_percent'] = round(msg['profit_percent'] * 100, 2) - message = "*{exchange}:* Selling [{pair}]({market_url})\n" \ - "*Limit:* `{limit:.8f}`\n" \ - "*Amount:* `{amount:.8f}`\n" \ - "*Open Rate:* `{open_rate:.8f}`\n" \ - "*Current Rate:* `{current_rate:.8f}`\n" \ - "*Profit:* `{profit_percent:.2f}%`".format(**msg) + message = ("*{exchange}:* Selling [{pair}]({market_url})\n" + "*Limit:* `{limit:.8f}`\n" + "*Amount:* `{amount:.8f}`\n" + "*Open Rate:* `{open_rate:.8f}`\n" + "*Current Rate:* `{current_rate:.8f}`\n" + "*Sell Reason:* `{sell_reason}`\n" + "*Profit:* `{profit_percent:.2f}%`").format(**msg) # Check if all sell properties are available. # This might not be the case if the message origin is triggered by /forcesell @@ -150,8 +151,8 @@ class Telegram(RPC): and self._fiat_converter): msg['profit_fiat'] = self._fiat_converter.convert_amount( msg['profit_amount'], msg['stake_currency'], msg['fiat_currency']) - message += '` ({gain}: {profit_amount:.8f} {stake_currency}`' \ - '` / {profit_fiat:.3f} {fiat_currency})`'.format(**msg) + message += ('` ({gain}: {profit_amount:.8f} {stake_currency}`' + '` / {profit_fiat:.3f} {fiat_currency})`').format(**msg) elif msg['type'] == RPCMessageType.STATUS_NOTIFICATION: message = '*Status:* `{status}`'.format(**msg)