From ee7cbcd69f63f0a021c20f4db96f698947e4acd7 Mon Sep 17 00:00:00 2001 From: Aezo Teo Date: Wed, 29 Dec 2021 21:48:50 +0800 Subject: [PATCH] fixed flake8 and mypy errors --- freqtrade/rpc/rpc.py | 2 +- freqtrade/rpc/telegram.py | 5 ++--- tests/rpc/test_rpc_telegram.py | 3 ++- tests/test_freqtradebot.py | 3 ++- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/freqtrade/rpc/rpc.py b/freqtrade/rpc/rpc.py index 09c61beca..2752f4d3c 100644 --- a/freqtrade/rpc/rpc.py +++ b/freqtrade/rpc/rpc.py @@ -245,7 +245,7 @@ class RPC: fiat_profit_sum = fiat_profit if isnan(fiat_profit_sum) \ else fiat_profit_sum + fiat_profit trades_list.append([ - trade.id + f' {direction_str}', + str(trade.id) + f' {direction_str}', trade.pair + ('*' if (trade.open_order_id is not None and trade.close_rate_requested is None) else '') + ('**' if (trade.close_rate_requested is not None) else ''), diff --git a/freqtrade/rpc/telegram.py b/freqtrade/rpc/telegram.py index 4bb63b0fd..03797bf93 100644 --- a/freqtrade/rpc/telegram.py +++ b/freqtrade/rpc/telegram.py @@ -272,7 +272,7 @@ class Telegram(RPCHandler): else: msg['profit_extra'] = '' is_fill = msg['type'] == RPCMessageType.SELL_FILL - message = [ + message = "".join([ f"{msg['emoji']} *{msg['exchange']}:* ", f"{'Exited' if is_fill else 'Exiting'} {msg['pair']} (#{msg['trade_id']})\n", f"*{'Profit' if is_fill else 'Unrealized Profit'}:* ", @@ -285,8 +285,7 @@ class Telegram(RPCHandler): msg.get('leverage', None) is not None else "", f"*Amount:* `{msg['amount']:.8f}`\n", f"*Open Rate:* `{msg['open_rate']:.8f}`\n" - ] - message = "".join(message) + ]) if msg['type'] == RPCMessageType.SELL: message += (f"*Current Rate:* `{msg['current_rate']:.8f}`\n" f"*Close Rate:* `{msg['limit']:.8f}`") diff --git a/tests/rpc/test_rpc_telegram.py b/tests/rpc/test_rpc_telegram.py index 5b214af9d..32b2a45a5 100644 --- a/tests/rpc/test_rpc_telegram.py +++ b/tests/rpc/test_rpc_telegram.py @@ -317,7 +317,8 @@ def test_status_table_handle(default_conf, update, ticker, fee, mocker) -> None: fields = re.sub('[ ]+', ' ', line[2].strip()).split(' ') assert int(fields[0]) == 1 - assert 'ETH/BTC' in fields[1] + assert 'L' in fields[1] + assert 'ETH/BTC' in fields[2] assert msg_mock.call_count == 1 diff --git a/tests/test_freqtradebot.py b/tests/test_freqtradebot.py index 65cb3693f..a3ab44839 100644 --- a/tests/test_freqtradebot.py +++ b/tests/test_freqtradebot.py @@ -2952,7 +2952,7 @@ def test_execute_trade_exit_down(default_conf_usdt, ticker_usdt, fee, ticker_usd "is_short,amount,open_rate,current_rate,limit,profit_amount," "profit_ratio,profit_or_loss", [ (False, 30, 2.0, 2.3, 2.25, 7.18125, 0.11938903, 'profit'), - (True, 29.70297029, 2.02, 2.2, 2.25, -7.14876237, -0.11944465, 'loss'), # TODO-lev + (True, 29.70297029, 2.02, 2.2, 2.25, -7.14876237, -0.11944465, 'loss'), # TODO-lev ]) def test_execute_trade_exit_custom_exit_price( default_conf_usdt, ticker_usdt, fee, ticker_usdt_sell_up, is_short, amount, open_rate, @@ -3190,6 +3190,7 @@ def test_execute_trade_exit_with_stoploss_on_exchange( assert cancel_order.call_count == 1 assert rpc_mock.call_count == 3 + # TODO-lev: add short, RPC short, short fill def test_may_execute_trade_exit_after_stoploss_on_exchange_hit(default_conf_usdt, ticker_usdt, fee, mocker) -> None: