From bd356f3eb45045ddef0c153c2694fc7bd7a44414 Mon Sep 17 00:00:00 2001 From: Samuel Husso Date: Sat, 20 Jan 2018 17:22:25 +0200 Subject: [PATCH 1/5] when selling, show more information about the trade in the message --- freqtrade/main.py | 19 ++++++++++++++++--- freqtrade/rpc/telegram.py | 6 +++--- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/freqtrade/main.py b/freqtrade/main.py index 27f3dfd9a..9e621bcbb 100755 --- a/freqtrade/main.py +++ b/freqtrade/main.py @@ -191,12 +191,25 @@ def execute_sell(trade: Trade, limit: float) -> None: fmt_exp_profit = round(trade.calc_profit_percent(rate=limit) * 100, 2) profit_trade = trade.calc_profit(rate=limit) - - message = '*{exchange}:* Selling [{pair}]({pair_url}) with limit `{limit:.8f}`'.format( + current_rate = exchange.get_ticker(trade.pair, False)['bid'] + current_profit = trade.calc_profit_percent(current_rate) + + message = """*{exchange}:* Selling +*Current Pair:* [{pair}]({pair_url}) +*Limit:* `{limit}` +*Amount:* `{amount}` +*Open Rate:* `{open_rate:.8f}` +*Current Rate:* `{current_rate:.8f}` +*Current Profit:* `{current_profit:.2f}%` + """.format( exchange=trade.exchange, pair=trade.pair.replace('_', '/'), pair_url=exchange.get_pair_detail_url(trade.pair), - limit=limit + limit=limit, + open_rate=trade.open_rate, + current_rate=current_rate, + amount=round(trade.amount, 8), + current_profit=round(current_profit * 100, 2), ) # For regular case, when the configuration exists diff --git a/freqtrade/rpc/telegram.py b/freqtrade/rpc/telegram.py index 0fdc734f4..596dd70dc 100644 --- a/freqtrade/rpc/telegram.py +++ b/freqtrade/rpc/telegram.py @@ -147,7 +147,7 @@ def _status(bot: Bot, update: Update) -> None: ) if trade.close_profit else None message = """ *Trade ID:* `{trade_id}` -*Current Pair:* [{pair}]({market_url}) +*Current Pair:* [{pair}]({pair_url}) *Open Since:* `{date}` *Amount:* `{amount}` *Open Rate:* `{open_rate:.8f}` @@ -158,8 +158,8 @@ def _status(bot: Bot, update: Update) -> None: *Open Order:* `{open_order}` """.format( trade_id=trade.id, - pair=trade.pair, - market_url=exchange.get_pair_detail_url(trade.pair), + pair=trade.pair.replace('_', '/'), + pair_url=exchange.get_pair_detail_url(trade.pair), date=arrow.get(trade.open_date).humanize(), open_rate=trade.open_rate, close_rate=trade.close_rate, From ddd62277c28eebe7b9b60503d16093f754e20534 Mon Sep 17 00:00:00 2001 From: Samuel Husso Date: Sat, 20 Jan 2018 17:50:23 +0200 Subject: [PATCH 2/5] add total amount of trades to /status --- freqtrade/rpc/telegram.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/freqtrade/rpc/telegram.py b/freqtrade/rpc/telegram.py index 596dd70dc..409427615 100644 --- a/freqtrade/rpc/telegram.py +++ b/freqtrade/rpc/telegram.py @@ -156,6 +156,7 @@ def _status(bot: Bot, update: Update) -> None: *Close Profit:* `{close_profit}` *Current Profit:* `{current_profit:.2f}%` *Open Order:* `{open_order}` +*Total Open Trades:* `{total_trades}` """.format( trade_id=trade.id, pair=trade.pair.replace('_', '/'), @@ -170,6 +171,7 @@ def _status(bot: Bot, update: Update) -> None: open_order='({} rem={:.8f})'.format( order['type'], order['remaining'] ) if order else None, + total_trades=len(trades) ) send_msg(message, bot=bot) From 6abbf45042eb49276b43bd46642a4a5620895b20 Mon Sep 17 00:00:00 2001 From: Samuel Husso Date: Sun, 21 Jan 2018 19:33:19 +0200 Subject: [PATCH 3/5] Update tests to reflect new selling msg --- freqtrade/main.py | 2 +- freqtrade/tests/rpc/test_rpc_telegram.py | 10 +++++++--- freqtrade/tests/test_main.py | 13 ++++++++++--- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/freqtrade/main.py b/freqtrade/main.py index 9e621bcbb..1d7f87585 100755 --- a/freqtrade/main.py +++ b/freqtrade/main.py @@ -193,7 +193,7 @@ def execute_sell(trade: Trade, limit: float) -> None: profit_trade = trade.calc_profit(rate=limit) current_rate = exchange.get_ticker(trade.pair, False)['bid'] current_profit = trade.calc_profit_percent(current_rate) - + message = """*{exchange}:* Selling *Current Pair:* [{pair}]({pair_url}) *Limit:* `{limit}` diff --git a/freqtrade/tests/rpc/test_rpc_telegram.py b/freqtrade/tests/rpc/test_rpc_telegram.py index 9c99be342..da616ae65 100644 --- a/freqtrade/tests/rpc/test_rpc_telegram.py +++ b/freqtrade/tests/rpc/test_rpc_telegram.py @@ -107,7 +107,7 @@ def test_status_handle(default_conf, update, ticker, mocker): _status(bot=MagicMock(), update=update) assert msg_mock.call_count == 1 - assert '[BTC_ETH]' in msg_mock.call_args_list[0][0][0] + assert '[BTC/ETH]' in msg_mock.call_args_list[0][0][0] def test_status_table_handle(default_conf, update, ticker, mocker): @@ -239,7 +239,9 @@ def test_forcesell_handle(default_conf, update, ticker, ticker_sell_up, mocker): _forcesell(bot=MagicMock(), update=update) assert rpc_mock.call_count == 2 - assert 'Selling [BTC/ETH]' in rpc_mock.call_args_list[-1][0][0] + assert 'Selling' in rpc_mock.call_args_list[-1][0][0] + assert '[BTC/ETH]' in rpc_mock.call_args_list[-1][0][0] + assert 'Amount' in rpc_mock.call_args_list[-1][0][0] assert '0.00001172' in rpc_mock.call_args_list[-1][0][0] assert 'profit: 6.11%, 0.00006126' in rpc_mock.call_args_list[-1][0][0] assert '0.919 USD' in rpc_mock.call_args_list[-1][0][0] @@ -276,7 +278,9 @@ def test_forcesell_down_handle(default_conf, update, ticker, ticker_sell_down, m _forcesell(bot=MagicMock(), update=update) assert rpc_mock.call_count == 2 - assert 'Selling [BTC/ETH]' in rpc_mock.call_args_list[-1][0][0] + assert 'Selling' in rpc_mock.call_args_list[-1][0][0] + assert '[BTC/ETH]' in rpc_mock.call_args_list[-1][0][0] + assert 'Amount' in rpc_mock.call_args_list[-1][0][0] assert '0.00001044' in rpc_mock.call_args_list[-1][0][0] assert 'loss: -5.48%, -0.00005492' in rpc_mock.call_args_list[-1][0][0] assert '-0.824 USD' in rpc_mock.call_args_list[-1][0][0] diff --git a/freqtrade/tests/test_main.py b/freqtrade/tests/test_main.py index a61342480..b8801df85 100644 --- a/freqtrade/tests/test_main.py +++ b/freqtrade/tests/test_main.py @@ -544,7 +544,10 @@ def test_execute_sell_up(default_conf, ticker, ticker_sell_up, mocker): execute_sell(trade=trade, limit=ticker_sell_up()['bid']) assert rpc_mock.call_count == 2 - assert 'Selling [BTC/ETH]' in rpc_mock.call_args_list[-1][0][0] + assert 'Selling' in rpc_mock.call_args_list[-1][0][0] + assert '[BTC/ETH]' in rpc_mock.call_args_list[-1][0][0] + assert 'Amount' in rpc_mock.call_args_list[-1][0][0] + assert 'Current Profit' in rpc_mock.call_args_list[-1][0][0] assert '0.00001172' in rpc_mock.call_args_list[-1][0][0] assert 'profit: 6.11%, 0.00006126' in rpc_mock.call_args_list[-1][0][0] assert '0.919 USD' in rpc_mock.call_args_list[-1][0][0] @@ -581,7 +584,9 @@ def test_execute_sell_down(default_conf, ticker, ticker_sell_down, mocker): execute_sell(trade=trade, limit=ticker_sell_down()['bid']) assert rpc_mock.call_count == 2 - assert 'Selling [BTC/ETH]' in rpc_mock.call_args_list[-1][0][0] + assert 'Selling' in rpc_mock.call_args_list[-1][0][0] + assert '[BTC/ETH]' in rpc_mock.call_args_list[-1][0][0] + assert 'Amount' in rpc_mock.call_args_list[-1][0][0] assert '0.00001044' in rpc_mock.call_args_list[-1][0][0] assert 'loss: -5.48%, -0.00005492' in rpc_mock.call_args_list[-1][0][0] assert '-0.824 USD' in rpc_mock.call_args_list[-1][0][0] @@ -644,7 +649,9 @@ def test_execute_sell_without_conf_sell_up(default_conf, ticker, ticker_sell_up, execute_sell(trade=trade, limit=ticker_sell_up()['bid']) assert rpc_mock.call_count == 2 - assert 'Selling [BTC/ETH]' in rpc_mock.call_args_list[-1][0][0] + assert 'Selling' in rpc_mock.call_args_list[-1][0][0] + assert '[BTC/ETH]' in rpc_mock.call_args_list[-1][0][0] + assert 'Amount' in rpc_mock.call_args_list[-1][0][0] assert '0.00001172' in rpc_mock.call_args_list[-1][0][0] assert '(profit: 6.11%, 0.00006126)' in rpc_mock.call_args_list[-1][0][0] assert 'USD' not in rpc_mock.call_args_list[-1][0][0] From bce6a7be61dfc35c187a57df935db40cbf6f80e8 Mon Sep 17 00:00:00 2001 From: Samuel Husso Date: Mon, 22 Jan 2018 09:39:11 +0200 Subject: [PATCH 4/5] rebase develop and update tests --- freqtrade/tests/test_main.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/freqtrade/tests/test_main.py b/freqtrade/tests/test_main.py index b8801df85..4c20f824d 100644 --- a/freqtrade/tests/test_main.py +++ b/freqtrade/tests/test_main.py @@ -616,10 +616,9 @@ def test_execute_sell_without_conf_sell_down(default_conf, ticker, ticker_sell_d execute_sell(trade=trade, limit=ticker_sell_down()['bid']) - print(rpc_mock.call_args_list[-1][0][0]) - assert rpc_mock.call_count == 2 - assert 'Selling [BTC/ETH]' in rpc_mock.call_args_list[-1][0][0] + assert 'Selling' in rpc_mock.call_args_list[-1][0][0] + assert '[BTC/ETH]' in rpc_mock.call_args_list[-1][0][0] assert '0.00001044' in rpc_mock.call_args_list[-1][0][0] assert 'loss: -5.48%, -0.00005492' in rpc_mock.call_args_list[-1][0][0] From 93bd63cfbed967f2a854a9ad0fc3335b9028726f Mon Sep 17 00:00:00 2001 From: Samuel Husso Date: Tue, 23 Jan 2018 08:55:22 +0200 Subject: [PATCH 5/5] get rid of / replacements, minor edit to outgoing msg --- freqtrade/main.py | 8 ++++---- freqtrade/rpc/telegram.py | 2 +- freqtrade/tests/rpc/test_rpc_telegram.py | 6 +++--- freqtrade/tests/test_main.py | 10 +++++----- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/freqtrade/main.py b/freqtrade/main.py index 1d7f87585..de64a6bd6 100755 --- a/freqtrade/main.py +++ b/freqtrade/main.py @@ -192,7 +192,7 @@ def execute_sell(trade: Trade, limit: float) -> None: fmt_exp_profit = round(trade.calc_profit_percent(rate=limit) * 100, 2) profit_trade = trade.calc_profit(rate=limit) current_rate = exchange.get_ticker(trade.pair, False)['bid'] - current_profit = trade.calc_profit_percent(current_rate) + profit = trade.calc_profit_percent(current_rate) message = """*{exchange}:* Selling *Current Pair:* [{pair}]({pair_url}) @@ -200,16 +200,16 @@ def execute_sell(trade: Trade, limit: float) -> None: *Amount:* `{amount}` *Open Rate:* `{open_rate:.8f}` *Current Rate:* `{current_rate:.8f}` -*Current Profit:* `{current_profit:.2f}%` +*Profit:* `{profit:.2f}%` """.format( exchange=trade.exchange, - pair=trade.pair.replace('_', '/'), + pair=trade.pair, pair_url=exchange.get_pair_detail_url(trade.pair), limit=limit, open_rate=trade.open_rate, current_rate=current_rate, amount=round(trade.amount, 8), - current_profit=round(current_profit * 100, 2), + profit=round(profit * 100, 2), ) # For regular case, when the configuration exists diff --git a/freqtrade/rpc/telegram.py b/freqtrade/rpc/telegram.py index 409427615..70d5a78f3 100644 --- a/freqtrade/rpc/telegram.py +++ b/freqtrade/rpc/telegram.py @@ -159,7 +159,7 @@ def _status(bot: Bot, update: Update) -> None: *Total Open Trades:* `{total_trades}` """.format( trade_id=trade.id, - pair=trade.pair.replace('_', '/'), + pair=trade.pair, pair_url=exchange.get_pair_detail_url(trade.pair), date=arrow.get(trade.open_date).humanize(), open_rate=trade.open_rate, diff --git a/freqtrade/tests/rpc/test_rpc_telegram.py b/freqtrade/tests/rpc/test_rpc_telegram.py index da616ae65..5e73fc911 100644 --- a/freqtrade/tests/rpc/test_rpc_telegram.py +++ b/freqtrade/tests/rpc/test_rpc_telegram.py @@ -107,7 +107,7 @@ def test_status_handle(default_conf, update, ticker, mocker): _status(bot=MagicMock(), update=update) assert msg_mock.call_count == 1 - assert '[BTC/ETH]' in msg_mock.call_args_list[0][0][0] + assert '[BTC_ETH]' in msg_mock.call_args_list[0][0][0] def test_status_table_handle(default_conf, update, ticker, mocker): @@ -240,7 +240,7 @@ def test_forcesell_handle(default_conf, update, ticker, ticker_sell_up, mocker): assert rpc_mock.call_count == 2 assert 'Selling' in rpc_mock.call_args_list[-1][0][0] - assert '[BTC/ETH]' in rpc_mock.call_args_list[-1][0][0] + assert '[BTC_ETH]' in rpc_mock.call_args_list[-1][0][0] assert 'Amount' in rpc_mock.call_args_list[-1][0][0] assert '0.00001172' in rpc_mock.call_args_list[-1][0][0] assert 'profit: 6.11%, 0.00006126' in rpc_mock.call_args_list[-1][0][0] @@ -279,7 +279,7 @@ def test_forcesell_down_handle(default_conf, update, ticker, ticker_sell_down, m assert rpc_mock.call_count == 2 assert 'Selling' in rpc_mock.call_args_list[-1][0][0] - assert '[BTC/ETH]' in rpc_mock.call_args_list[-1][0][0] + assert '[BTC_ETH]' in rpc_mock.call_args_list[-1][0][0] assert 'Amount' in rpc_mock.call_args_list[-1][0][0] assert '0.00001044' in rpc_mock.call_args_list[-1][0][0] assert 'loss: -5.48%, -0.00005492' in rpc_mock.call_args_list[-1][0][0] diff --git a/freqtrade/tests/test_main.py b/freqtrade/tests/test_main.py index 4c20f824d..ceaa64969 100644 --- a/freqtrade/tests/test_main.py +++ b/freqtrade/tests/test_main.py @@ -545,9 +545,9 @@ def test_execute_sell_up(default_conf, ticker, ticker_sell_up, mocker): assert rpc_mock.call_count == 2 assert 'Selling' in rpc_mock.call_args_list[-1][0][0] - assert '[BTC/ETH]' in rpc_mock.call_args_list[-1][0][0] + assert '[BTC_ETH]' in rpc_mock.call_args_list[-1][0][0] assert 'Amount' in rpc_mock.call_args_list[-1][0][0] - assert 'Current Profit' in rpc_mock.call_args_list[-1][0][0] + assert 'Profit' in rpc_mock.call_args_list[-1][0][0] assert '0.00001172' in rpc_mock.call_args_list[-1][0][0] assert 'profit: 6.11%, 0.00006126' in rpc_mock.call_args_list[-1][0][0] assert '0.919 USD' in rpc_mock.call_args_list[-1][0][0] @@ -585,7 +585,7 @@ def test_execute_sell_down(default_conf, ticker, ticker_sell_down, mocker): assert rpc_mock.call_count == 2 assert 'Selling' in rpc_mock.call_args_list[-1][0][0] - assert '[BTC/ETH]' in rpc_mock.call_args_list[-1][0][0] + assert '[BTC_ETH]' in rpc_mock.call_args_list[-1][0][0] assert 'Amount' in rpc_mock.call_args_list[-1][0][0] assert '0.00001044' in rpc_mock.call_args_list[-1][0][0] assert 'loss: -5.48%, -0.00005492' in rpc_mock.call_args_list[-1][0][0] @@ -618,7 +618,7 @@ def test_execute_sell_without_conf_sell_down(default_conf, ticker, ticker_sell_d assert rpc_mock.call_count == 2 assert 'Selling' in rpc_mock.call_args_list[-1][0][0] - assert '[BTC/ETH]' in rpc_mock.call_args_list[-1][0][0] + assert '[BTC_ETH]' in rpc_mock.call_args_list[-1][0][0] assert '0.00001044' in rpc_mock.call_args_list[-1][0][0] assert 'loss: -5.48%, -0.00005492' in rpc_mock.call_args_list[-1][0][0] @@ -649,7 +649,7 @@ def test_execute_sell_without_conf_sell_up(default_conf, ticker, ticker_sell_up, assert rpc_mock.call_count == 2 assert 'Selling' in rpc_mock.call_args_list[-1][0][0] - assert '[BTC/ETH]' in rpc_mock.call_args_list[-1][0][0] + assert '[BTC_ETH]' in rpc_mock.call_args_list[-1][0][0] assert 'Amount' in rpc_mock.call_args_list[-1][0][0] assert '0.00001172' in rpc_mock.call_args_list[-1][0][0] assert '(profit: 6.11%, 0.00006126)' in rpc_mock.call_args_list[-1][0][0]