Improve code formatting of telegram
This commit is contained in:
parent
ed1268cf39
commit
8d8cf5a2fd
@ -144,8 +144,8 @@ class Telegram(RPC):
|
|||||||
message += ")`"
|
message += ")`"
|
||||||
|
|
||||||
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}".format(**msg)
|
"Cancelling Open Buy Order for {pair}".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)
|
||||||
@ -388,11 +388,11 @@ class Telegram(RPC):
|
|||||||
)
|
)
|
||||||
for currency in result['currencies']:
|
for currency in result['currencies']:
|
||||||
if currency['est_stake'] > 0.0001:
|
if currency['est_stake'] > 0.0001:
|
||||||
curr_output = "*{currency}:*\n" \
|
curr_output = ("*{currency}:*\n"
|
||||||
"\t`Available: {free: .8f}`\n" \
|
"\t`Available: {free: .8f}`\n"
|
||||||
"\t`Balance: {balance: .8f}`\n" \
|
"\t`Balance: {balance: .8f}`\n"
|
||||||
"\t`Pending: {used: .8f}`\n" \
|
"\t`Pending: {used: .8f}`\n"
|
||||||
"\t`Est. {stake}: {est_stake: .8f}`\n".format(**currency)
|
"\t`Est. {stake}: {est_stake: .8f}`\n").format(**currency)
|
||||||
else:
|
else:
|
||||||
curr_output = "*{currency}:* not showing <1$ amount \n".format(**currency)
|
curr_output = "*{currency}:* not showing <1$ amount \n".format(**currency)
|
||||||
|
|
||||||
@ -403,9 +403,9 @@ class Telegram(RPC):
|
|||||||
else:
|
else:
|
||||||
output += curr_output
|
output += curr_output
|
||||||
|
|
||||||
output += "\n*Estimated Value*:\n" \
|
output += ("\n*Estimated Value*:\n"
|
||||||
"\t`{stake}: {total: .8f}`\n" \
|
"\t`{stake}: {total: .8f}`\n"
|
||||||
"\t`{symbol}: {value: .2f}`\n".format(**result)
|
"\t`{symbol}: {value: .2f}`\n").format(**result)
|
||||||
self._send_msg(output)
|
self._send_msg(output)
|
||||||
except RPCException as e:
|
except RPCException as e:
|
||||||
self._send_msg(str(e))
|
self._send_msg(str(e))
|
||||||
@ -598,32 +598,32 @@ class Telegram(RPC):
|
|||||||
:param update: message update
|
:param update: message update
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
forcebuy_text = "*/forcebuy <pair> [<rate>]:* `Instantly buys the given pair. " \
|
forcebuy_text = ("*/forcebuy <pair> [<rate>]:* `Instantly buys the given pair. "
|
||||||
"Optionally takes a rate at which to buy.` \n"
|
"Optionally takes a rate at which to buy.` \n")
|
||||||
message = "*/start:* `Starts the trader`\n" \
|
message = ("*/start:* `Starts the trader`\n"
|
||||||
"*/stop:* `Stops the trader`\n" \
|
"*/stop:* `Stops the trader`\n"
|
||||||
"*/status [table]:* `Lists all open trades`\n" \
|
"*/status [table]:* `Lists all open trades`\n"
|
||||||
" *table :* `will display trades in a table`\n" \
|
" *table :* `will display trades in a table`\n"
|
||||||
" `pending buy orders are marked with an asterisk (*)`\n" \
|
" `pending buy orders are marked with an asterisk (*)`\n"
|
||||||
" `pending sell orders are marked with a double asterisk (**)`\n" \
|
" `pending sell orders are marked with a double asterisk (**)`\n"
|
||||||
"*/profit:* `Lists cumulative profit from all finished trades`\n" \
|
"*/profit:* `Lists cumulative profit from all finished trades`\n"
|
||||||
"*/forcesell <trade_id>|all:* `Instantly sells the given trade or all trades, " \
|
"*/forcesell <trade_id>|all:* `Instantly sells the given trade or all trades, "
|
||||||
"regardless of profit`\n" \
|
"regardless of profit`\n"
|
||||||
f"{forcebuy_text if self._config.get('forcebuy_enable', False) else ''}" \
|
f"{forcebuy_text if self._config.get('forcebuy_enable', False) else ''}"
|
||||||
"*/performance:* `Show performance of each finished trade grouped by pair`\n" \
|
"*/performance:* `Show performance of each finished trade grouped by pair`\n"
|
||||||
"*/daily <n>:* `Shows profit or loss per day, over the last n days`\n" \
|
"*/daily <n>:* `Shows profit or loss per day, over the last n days`\n"
|
||||||
"*/count:* `Show number of trades running compared to allowed number of trades`" \
|
"*/count:* `Show number of trades running compared to allowed number of trades`"
|
||||||
"\n" \
|
"\n"
|
||||||
"*/balance:* `Show account balance per currency`\n" \
|
"*/balance:* `Show account balance per currency`\n"
|
||||||
"*/stopbuy:* `Stops buying, but handles open trades gracefully` \n" \
|
"*/stopbuy:* `Stops buying, but handles open trades gracefully` \n"
|
||||||
"*/reload_conf:* `Reload configuration file` \n" \
|
"*/reload_conf:* `Reload configuration file` \n"
|
||||||
"*/show_config:* `Show running configuration` \n" \
|
"*/show_config:* `Show running configuration` \n"
|
||||||
"*/whitelist:* `Show current whitelist` \n" \
|
"*/whitelist:* `Show current whitelist` \n"
|
||||||
"*/blacklist [pair]:* `Show current blacklist, or adds one or more pairs " \
|
"*/blacklist [pair]:* `Show current blacklist, or adds one or more pairs "
|
||||||
"to the blacklist.` \n" \
|
"to the blacklist.` \n"
|
||||||
"*/edge:* `Shows validated pairs by Edge if it is enabled` \n" \
|
"*/edge:* `Shows validated pairs by Edge if it is enabled` \n"
|
||||||
"*/help:* `This help message`\n" \
|
"*/help:* `This help message`\n"
|
||||||
"*/version:* `Show version`"
|
"*/version:* `Show version`")
|
||||||
|
|
||||||
self._send_msg(message)
|
self._send_msg(message)
|
||||||
|
|
||||||
|
@ -71,10 +71,10 @@ def test_init(default_conf, mocker, caplog) -> None:
|
|||||||
assert start_polling.dispatcher.add_handler.call_count > 0
|
assert start_polling.dispatcher.add_handler.call_count > 0
|
||||||
assert start_polling.start_polling.call_count == 1
|
assert start_polling.start_polling.call_count == 1
|
||||||
|
|
||||||
message_str = "rpc.telegram is listening for following commands: [['status'], ['profit'], " \
|
message_str = ("rpc.telegram is listening for following commands: [['status'], ['profit'], "
|
||||||
"['balance'], ['start'], ['stop'], ['forcesell'], ['forcebuy'], " \
|
"['balance'], ['start'], ['stop'], ['forcesell'], ['forcebuy'], "
|
||||||
"['performance'], ['daily'], ['count'], ['reload_conf'], ['show_config'], " \
|
"['performance'], ['daily'], ['count'], ['reload_conf'], ['show_config'], "
|
||||||
"['stopbuy'], ['whitelist'], ['blacklist'], ['edge'], ['help'], ['version']]"
|
"['stopbuy'], ['whitelist'], ['blacklist'], ['edge'], ['help'], ['version']]")
|
||||||
|
|
||||||
assert log_has(message_str, caplog)
|
assert log_has(message_str, caplog)
|
||||||
|
|
||||||
@ -1016,9 +1016,8 @@ def test_count_handle(default_conf, update, ticker, fee, mocker) -> None:
|
|||||||
msg_mock.reset_mock()
|
msg_mock.reset_mock()
|
||||||
telegram._count(update=update, context=MagicMock())
|
telegram._count(update=update, context=MagicMock())
|
||||||
|
|
||||||
msg = '<pre> current max total stake\n--------- ----- -------------\n' \
|
msg = ('<pre> current max total stake\n--------- ----- -------------\n'
|
||||||
' 1 {} {}</pre>'\
|
' 1 {} {}</pre>').format(
|
||||||
.format(
|
|
||||||
default_conf['max_open_trades'],
|
default_conf['max_open_trades'],
|
||||||
default_conf['stake_amount']
|
default_conf['stake_amount']
|
||||||
)
|
)
|
||||||
@ -1441,12 +1440,11 @@ def test_send_msg_buy_notification_no_fiat(default_conf, mocker) -> None:
|
|||||||
'amount': 1333.3333333333335,
|
'amount': 1333.3333333333335,
|
||||||
'open_date': arrow.utcnow().shift(hours=-1)
|
'open_date': arrow.utcnow().shift(hours=-1)
|
||||||
})
|
})
|
||||||
assert msg_mock.call_args[0][0] \
|
assert msg_mock.call_args[0][0] == ('\N{LARGE BLUE CIRCLE} *Bittrex:* Buying ETH/BTC\n'
|
||||||
== '\N{LARGE BLUE CIRCLE} *Bittrex:* Buying ETH/BTC\n' \
|
'*Amount:* `1333.33333333`\n'
|
||||||
'*Amount:* `1333.33333333`\n' \
|
'*Open Rate:* `0.00001099`\n'
|
||||||
'*Open Rate:* `0.00001099`\n' \
|
'*Current Rate:* `0.00001099`\n'
|
||||||
'*Current Rate:* `0.00001099`\n' \
|
'*Total:* `(0.001000 BTC)`')
|
||||||
'*Total:* `(0.001000 BTC)`'
|
|
||||||
|
|
||||||
|
|
||||||
def test_send_msg_sell_notification_no_fiat(default_conf, mocker) -> None:
|
def test_send_msg_sell_notification_no_fiat(default_conf, mocker) -> None:
|
||||||
@ -1477,15 +1475,14 @@ def test_send_msg_sell_notification_no_fiat(default_conf, mocker) -> None:
|
|||||||
'open_date': arrow.utcnow().shift(hours=-2, minutes=-35, seconds=-3),
|
'open_date': arrow.utcnow().shift(hours=-2, minutes=-35, seconds=-3),
|
||||||
'close_date': arrow.utcnow(),
|
'close_date': arrow.utcnow(),
|
||||||
})
|
})
|
||||||
assert msg_mock.call_args[0][0] \
|
assert msg_mock.call_args[0][0] == ('\N{WARNING SIGN} *Binance:* Selling KEY/ETH\n'
|
||||||
== '\N{WARNING SIGN} *Binance:* Selling KEY/ETH\n' \
|
'*Amount:* `1333.33333333`\n'
|
||||||
'*Amount:* `1333.33333333`\n' \
|
'*Open Rate:* `0.00007500`\n'
|
||||||
'*Open Rate:* `0.00007500`\n' \
|
'*Current Rate:* `0.00003201`\n'
|
||||||
'*Current Rate:* `0.00003201`\n' \
|
'*Close Rate:* `0.00003201`\n'
|
||||||
'*Close Rate:* `0.00003201`\n' \
|
'*Sell Reason:* `stop_loss`\n'
|
||||||
'*Sell Reason:* `stop_loss`\n' \
|
'*Duration:* `2:35:03 (155.1 min)`\n'
|
||||||
'*Duration:* `2:35:03 (155.1 min)`\n' \
|
'*Profit:* `-57.41%`')
|
||||||
'*Profit:* `-57.41%`'
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('msg,expected', [
|
@pytest.mark.parametrize('msg,expected', [
|
||||||
|
Loading…
Reference in New Issue
Block a user