Add trade_id to Cancel messages and reduced lines length
This commit is contained in:
		| @@ -193,7 +193,8 @@ class Telegram(RPCHandler): | |||||||
|             else: |             else: | ||||||
|                 msg['stake_amount_fiat'] = 0 |                 msg['stake_amount_fiat'] = 0 | ||||||
|  |  | ||||||
|             message = (f"\N{LARGE BLUE CIRCLE} *{msg['exchange']}:* Buying {msg['pair']} (#{msg['trade_id']})\n" |             message = (f"\N{LARGE BLUE CIRCLE} *{msg['exchange']}:* Buying {msg['pair']}" | ||||||
|  |                        f" (#{msg['trade_id']})\n" | ||||||
|                        f"*Amount:* `{msg['amount']:.8f}`\n" |                        f"*Amount:* `{msg['amount']:.8f}`\n" | ||||||
|                        f"*Open Rate:* `{msg['limit']:.8f}`\n" |                        f"*Open Rate:* `{msg['limit']:.8f}`\n" | ||||||
|                        f"*Current Rate:* `{msg['current_rate']:.8f}`\n" |                        f"*Current Rate:* `{msg['current_rate']:.8f}`\n" | ||||||
| @@ -205,7 +206,8 @@ class Telegram(RPCHandler): | |||||||
|  |  | ||||||
|         elif msg['type'] == RPCMessageType.BUY_CANCEL_NOTIFICATION: |         elif msg['type'] == RPCMessageType.BUY_CANCEL_NOTIFICATION: | ||||||
|             message = ("\N{WARNING SIGN} *{exchange}:* " |             message = ("\N{WARNING SIGN} *{exchange}:* " | ||||||
|                        "Cancelling open buy Order for {pair}. Reason: {reason}.".format(**msg)) |                        "Cancelling open buy Order for {pair} (#{trade_id}). " | ||||||
|  |                        "Reason: {reason}.".format(**msg)) | ||||||
|  |  | ||||||
|         elif msg['type'] == RPCMessageType.SELL_NOTIFICATION: |         elif msg['type'] == RPCMessageType.SELL_NOTIFICATION: | ||||||
|             msg['amount'] = round(msg['amount'], 8) |             msg['amount'] = round(msg['amount'], 8) | ||||||
| @@ -236,7 +238,7 @@ class Telegram(RPCHandler): | |||||||
|  |  | ||||||
|         elif msg['type'] == RPCMessageType.SELL_CANCEL_NOTIFICATION: |         elif msg['type'] == RPCMessageType.SELL_CANCEL_NOTIFICATION: | ||||||
|             message = ("\N{WARNING SIGN} *{exchange}:* Cancelling Open Sell Order " |             message = ("\N{WARNING SIGN} *{exchange}:* Cancelling Open Sell Order " | ||||||
|                        "for {pair}. Reason: {reason}").format(**msg) |                        "for {pair} (#{trade_id}). Reason: {reason}").format(**msg) | ||||||
|  |  | ||||||
|         elif msg['type'] == RPCMessageType.STATUS_NOTIFICATION: |         elif msg['type'] == RPCMessageType.STATUS_NOTIFICATION: | ||||||
|             message = '*Status:* `{status}`'.format(**msg) |             message = '*Status:* `{status}`'.format(**msg) | ||||||
|   | |||||||
| @@ -1241,12 +1241,14 @@ def test_send_msg_buy_cancel_notification(default_conf, mocker) -> None: | |||||||
|  |  | ||||||
|     telegram.send_msg({ |     telegram.send_msg({ | ||||||
|         'type': RPCMessageType.BUY_CANCEL_NOTIFICATION, |         'type': RPCMessageType.BUY_CANCEL_NOTIFICATION, | ||||||
|  |         'trade_id': 1, | ||||||
|         'exchange': 'Bittrex', |         'exchange': 'Bittrex', | ||||||
|         'pair': 'ETH/BTC', |         'pair': 'ETH/BTC', | ||||||
|         'reason': CANCEL_REASON['TIMEOUT'] |         'reason': CANCEL_REASON['TIMEOUT'] | ||||||
|     }) |     }) | ||||||
|     assert (msg_mock.call_args[0][0] == '\N{WARNING SIGN} *Bittrex:* ' |     assert (msg_mock.call_args[0][0] == '\N{WARNING SIGN} *Bittrex:* ' | ||||||
|             'Cancelling open buy Order for ETH/BTC. Reason: cancelled due to timeout.') |             'Cancelling open buy Order for ETH/BTC (#1). ' | ||||||
|  |             'Reason: cancelled due to timeout.') | ||||||
|  |  | ||||||
|  |  | ||||||
| def test_send_msg_sell_notification(default_conf, mocker) -> None: | def test_send_msg_sell_notification(default_conf, mocker) -> None: | ||||||
| @@ -1324,23 +1326,26 @@ def test_send_msg_sell_cancel_notification(default_conf, mocker) -> None: | |||||||
|     telegram._rpc._fiat_converter.convert_amount = lambda a, b, c: -24.812 |     telegram._rpc._fiat_converter.convert_amount = lambda a, b, c: -24.812 | ||||||
|     telegram.send_msg({ |     telegram.send_msg({ | ||||||
|         'type': RPCMessageType.SELL_CANCEL_NOTIFICATION, |         'type': RPCMessageType.SELL_CANCEL_NOTIFICATION, | ||||||
|  |         'trade_id': 1, | ||||||
|         'exchange': 'Binance', |         'exchange': 'Binance', | ||||||
|         'pair': 'KEY/ETH', |         'pair': 'KEY/ETH', | ||||||
|         'reason': 'Cancelled on exchange' |         'reason': 'Cancelled on exchange' | ||||||
|     }) |     }) | ||||||
|     assert msg_mock.call_args[0][0] \ |     assert msg_mock.call_args[0][0] \ | ||||||
|         == ('\N{WARNING SIGN} *Binance:* Cancelling Open Sell Order for KEY/ETH. ' |         == ('\N{WARNING SIGN} *Binance:* Cancelling Open Sell Order for KEY/ETH (#1).' | ||||||
|             ' Reason: Cancelled on exchange') |             ' Reason: Cancelled on exchange') | ||||||
|  |  | ||||||
|     msg_mock.reset_mock() |     msg_mock.reset_mock() | ||||||
|     telegram.send_msg({ |     telegram.send_msg({ | ||||||
|         'type': RPCMessageType.SELL_CANCEL_NOTIFICATION, |         'type': RPCMessageType.SELL_CANCEL_NOTIFICATION, | ||||||
|  |         'trade_id': 1, | ||||||
|         'exchange': 'Binance', |         'exchange': 'Binance', | ||||||
|         'pair': 'KEY/ETH', |         'pair': 'KEY/ETH', | ||||||
|         'reason': 'timeout' |         'reason': 'timeout' | ||||||
|     }) |     }) | ||||||
|     assert msg_mock.call_args[0][0] \ |     assert msg_mock.call_args[0][0] \ | ||||||
|         == ('\N{WARNING SIGN} *Binance:* Cancelling Open Sell Order for KEY/ETH. Reason: timeout') |         == ('\N{WARNING SIGN} *Binance:* Cancelling Open Sell Order for KEY/ETH (#1).' | ||||||
|  |             ' Reason: timeout') | ||||||
|     # Reset singleton function to avoid random breaks |     # Reset singleton function to avoid random breaks | ||||||
|     telegram._rpc._fiat_converter.convert_amount = old_convamount |     telegram._rpc._fiat_converter.convert_amount = old_convamount | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user