From a965436cd6443f41ed0f906eed8b8a025de7e0ea Mon Sep 17 00:00:00 2001 From: Eugene Schava Date: Fri, 28 May 2021 10:17:26 +0300 Subject: [PATCH] day/week options for Telegram '/profit' command format changed to "/profit n" --- README.md | 2 +- docs/telegram-usage.md | 4 ++-- freqtrade/rpc/telegram.py | 19 ++++++++++--------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index ada31b42b..2730ee85d 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,7 @@ Telegram is not mandatory. However, this is a great way to control your bot. Mor - `/stop`: Stops the trader. - `/stopbuy`: Stop entering new trades. - `/status |[table]`: Lists all or specific open trades. -- `/profit [day]|[week]`: Lists cumulative profit from all finished trades +- `/profit []`: Lists cumulative profit from all finished trades, over the last n days. - `/forcesell |all`: Instantly sells the given trade (Ignoring `minimum_roi`). - `/performance`: Show performance of each finished trade grouped by pair - `/balance`: Show account balance per currency. diff --git a/docs/telegram-usage.md b/docs/telegram-usage.md index c477921de..0e6bae380 100644 --- a/docs/telegram-usage.md +++ b/docs/telegram-usage.md @@ -130,7 +130,7 @@ You can create your own keyboard in `config.json`: !!! Note "Supported Commands" Only the following commands are allowed. Command arguments are not supported! - `/start`, `/stop`, `/status`, `/status table`, `/trades`, `/profit`, `/profit day`, `/profit week`, `/performance`, `/daily`, `/stats`, `/count`, `/locks`, `/balance`, `/stopbuy`, `/reload_config`, `/show_config`, `/logs`, `/whitelist`, `/blacklist`, `/edge`, `/help`, `/version` + `/start`, `/stop`, `/status`, `/status table`, `/trades`, `/profit`, `/performance`, `/daily`, `/stats`, `/count`, `/locks`, `/balance`, `/stopbuy`, `/reload_config`, `/show_config`, `/logs`, `/whitelist`, `/blacklist`, `/edge`, `/help`, `/version` ## Telegram commands @@ -154,7 +154,7 @@ official commands. You can ask at any moment for help with `/help`. | `/count` | Displays number of trades used and available | `/locks` | Show currently locked pairs. | `/unlock ` | Remove the lock for this pair (or for this lock id). -| `/profit [day]|[week]` | Display a summary of your profit/loss from close trades and some stats about your performance +| `/profit []` | Display a summary of your profit/loss from close trades and some stats about your performance, over the last n days (all trades by default) | `/forcesell ` | Instantly sells the given trade (Ignoring `minimum_roi`). | `/forcesell all` | Instantly sells all open trades (Ignoring `minimum_roi`). | `/forcebuy [rate]` | Instantly buys the given pair. Rate is optional. (`forcebuy_enable` must be set to True) diff --git a/freqtrade/rpc/telegram.py b/freqtrade/rpc/telegram.py index 19c520efa..4be990b96 100644 --- a/freqtrade/rpc/telegram.py +++ b/freqtrade/rpc/telegram.py @@ -206,13 +206,14 @@ class Telegram(RPCHandler): msg['emoji'] = self._get_sell_emoji(msg) message = ("{emoji} *{exchange}:* Selling {pair} (#{trade_id})\n" + "*Profit:* `{profit_percent:.2f}%`\n" + "*Sell Reason:* `{sell_reason}`\n" + "*Duration:* `{duration} ({duration_min:.1f} min)`\n" "*Amount:* `{amount:.8f}`\n" "*Open Rate:* `{open_rate:.8f}`\n" "*Current Rate:* `{current_rate:.8f}`\n" - "*Close Rate:* `{limit:.8f}`\n" - "*Sell Reason:* `{sell_reason}`\n" - "*Duration:* `{duration} ({duration_min:.1f} min)`\n" - "*Profit:* `{profit_percent:.2f}%`").format(**msg) + "*Close Rate:* `{limit:.8f}`" + ).format(**msg) # Check if all sell properties are available. # This might not be the case if the message origin is triggered by /forcesell @@ -423,11 +424,11 @@ class Telegram(RPCHandler): fiat_disp_cur = self._config.get('fiat_display_currency', '') start_date = datetime.fromtimestamp(0) - if context.args: - if 'day' in context.args: - start_date = datetime.combine(date.today(), datetime.min.time()) - elif 'week' in context.args: - start_date = datetime.combine(date.today(), datetime.min.time()) - timedelta(days=7) + try: + timescale = int(context.args[0]) if context.args else None + start_date = datetime.combine(date.today(), datetime.min.time()) - timedelta(days=timescale) + except (TypeError, ValueError, IndexError): + pass stats = self._rpc._rpc_trade_statistics( stake_cur,