Improve coin value output by rounding coin specific
This commit is contained in:
parent
072abde9b7
commit
e7acee7904
@ -10,7 +10,7 @@ from tabulate import tabulate
|
|||||||
|
|
||||||
from freqtrade.constants import DATETIME_PRINT_FORMAT, LAST_BT_RESULT_FN
|
from freqtrade.constants import DATETIME_PRINT_FORMAT, LAST_BT_RESULT_FN
|
||||||
from freqtrade.data.btanalysis import calculate_market_change, calculate_max_drawdown
|
from freqtrade.data.btanalysis import calculate_market_change, calculate_max_drawdown
|
||||||
from freqtrade.misc import file_dump_json, round_coin_value, decimals_per_coin
|
from freqtrade.misc import decimals_per_coin, file_dump_json, round_coin_value
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@ -384,7 +384,9 @@ def text_table_sell_reason(sell_reason_stats: List[Dict[str, Any]], stake_curren
|
|||||||
|
|
||||||
output = [[
|
output = [[
|
||||||
t['sell_reason'], t['trades'], t['wins'], t['draws'], t['losses'],
|
t['sell_reason'], t['trades'], t['wins'], t['draws'], t['losses'],
|
||||||
t['profit_mean_pct'], t['profit_sum_pct'], t['profit_total_abs'], t['profit_total_pct'],
|
t['profit_mean_pct'], t['profit_sum_pct'],
|
||||||
|
round_coin_value(t['profit_total_abs'], stake_currency, False),
|
||||||
|
t['profit_total_pct'],
|
||||||
] for t in sell_reason_stats]
|
] for t in sell_reason_stats]
|
||||||
return tabulate(output, headers=headers, tablefmt="orgtbl", stralign="right")
|
return tabulate(output, headers=headers, tablefmt="orgtbl", stralign="right")
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ from telegram.utils.helpers import escape_markdown
|
|||||||
|
|
||||||
from freqtrade.__init__ import __version__
|
from freqtrade.__init__ import __version__
|
||||||
from freqtrade.exceptions import OperationalException
|
from freqtrade.exceptions import OperationalException
|
||||||
|
from freqtrade.misc import round_coin_value
|
||||||
from freqtrade.rpc import RPC, RPCException, RPCHandler, RPCMessageType
|
from freqtrade.rpc import RPC, RPCException, RPCHandler, RPCMessageType
|
||||||
|
|
||||||
|
|
||||||
@ -189,14 +190,14 @@ class Telegram(RPCHandler):
|
|||||||
else:
|
else:
|
||||||
msg['stake_amount_fiat'] = 0
|
msg['stake_amount_fiat'] = 0
|
||||||
|
|
||||||
message = ("\N{LARGE BLUE CIRCLE} *{exchange}:* Buying {pair}\n"
|
message = (f"\N{LARGE BLUE CIRCLE} *{msg['exchange']}:* Buying {msg['pair']}\n"
|
||||||
"*Amount:* `{amount:.8f}`\n"
|
f"*Amount:* `{msg['amount']:.8f}`\n"
|
||||||
"*Open Rate:* `{limit:.8f}`\n"
|
f"*Open Rate:* `{msg['limit']:.8f}`\n"
|
||||||
"*Current Rate:* `{current_rate:.8f}`\n"
|
f"*Current Rate:* `{msg['current_rate']:.8f}`\n"
|
||||||
"*Total:* `({stake_amount:.6f} {stake_currency}").format(**msg)
|
f"*Total:* `({round_coin_value(msg['stake_amount'], msg['stake_currency'])}")
|
||||||
|
|
||||||
if msg.get('fiat_currency', None):
|
if msg.get('fiat_currency', None):
|
||||||
message += ", {stake_amount_fiat:.3f} {fiat_currency}".format(**msg)
|
message += f", {round_coin_value(msg['stake_amount_fiat'], msg['fiat_currency'])}"
|
||||||
message += ")`"
|
message += ")`"
|
||||||
|
|
||||||
elif msg['type'] == RPCMessageType.BUY_CANCEL_NOTIFICATION:
|
elif msg['type'] == RPCMessageType.BUY_CANCEL_NOTIFICATION:
|
||||||
@ -365,7 +366,7 @@ class Telegram(RPCHandler):
|
|||||||
)
|
)
|
||||||
stats_tab = tabulate(
|
stats_tab = tabulate(
|
||||||
[[day['date'],
|
[[day['date'],
|
||||||
f"{day['abs_profit']:.8f} {stats['stake_currency']}",
|
f"{round_coin_value(day['abs_profit'], stats['stake_currency'])}",
|
||||||
f"{day['fiat_value']:.3f} {stats['fiat_display_currency']}",
|
f"{day['fiat_value']:.3f} {stats['fiat_display_currency']}",
|
||||||
f"{day['trade_count']} trades"] for day in stats['data']],
|
f"{day['trade_count']} trades"] for day in stats['data']],
|
||||||
headers=[
|
headers=[
|
||||||
@ -415,18 +416,18 @@ class Telegram(RPCHandler):
|
|||||||
# Message to display
|
# Message to display
|
||||||
if stats['closed_trade_count'] > 0:
|
if stats['closed_trade_count'] > 0:
|
||||||
markdown_msg = ("*ROI:* Closed trades\n"
|
markdown_msg = ("*ROI:* Closed trades\n"
|
||||||
f"∙ `{profit_closed_coin:.8f} {stake_cur} "
|
f"∙ `{round_coin_value(profit_closed_coin, stake_cur)} "
|
||||||
f"({profit_closed_percent_mean:.2f}%) "
|
f"({profit_closed_percent_mean:.2f}%) "
|
||||||
f"({profit_closed_percent_sum} \N{GREEK CAPITAL LETTER SIGMA}%)`\n"
|
f"({profit_closed_percent_sum} \N{GREEK CAPITAL LETTER SIGMA}%)`\n"
|
||||||
f"∙ `{profit_closed_fiat:.3f} {fiat_disp_cur}`\n")
|
f"∙ `{round_coin_value(profit_closed_fiat, fiat_disp_cur)}`\n")
|
||||||
else:
|
else:
|
||||||
markdown_msg = "`No closed trade` \n"
|
markdown_msg = "`No closed trade` \n"
|
||||||
|
|
||||||
markdown_msg += (f"*ROI:* All trades\n"
|
markdown_msg += (f"*ROI:* All trades\n"
|
||||||
f"∙ `{profit_all_coin:.8f} {stake_cur} "
|
f"∙ `{round_coin_value(profit_all_coin, stake_cur)} "
|
||||||
f"({profit_all_percent_mean:.2f}%) "
|
f"({profit_all_percent_mean:.2f}%) "
|
||||||
f"({profit_all_percent_sum} \N{GREEK CAPITAL LETTER SIGMA}%)`\n"
|
f"({profit_all_percent_sum} \N{GREEK CAPITAL LETTER SIGMA}%)`\n"
|
||||||
f"∙ `{profit_all_fiat:.3f} {fiat_disp_cur}`\n"
|
f"∙ `{round_coin_value(profit_all_fiat, fiat_disp_cur)}`\n"
|
||||||
f"*Total Trade Count:* `{trade_count}`\n"
|
f"*Total Trade Count:* `{trade_count}`\n"
|
||||||
f"*First Trade opened:* `{first_trade_date}`\n"
|
f"*First Trade opened:* `{first_trade_date}`\n"
|
||||||
f"*Latest Trade opened:* `{latest_trade_date}\n`"
|
f"*Latest Trade opened:* `{latest_trade_date}\n`"
|
||||||
@ -494,15 +495,17 @@ class Telegram(RPCHandler):
|
|||||||
"Starting capital: "
|
"Starting capital: "
|
||||||
f"`{self._config['dry_run_wallet']}` {self._config['stake_currency']}.\n"
|
f"`{self._config['dry_run_wallet']}` {self._config['stake_currency']}.\n"
|
||||||
)
|
)
|
||||||
for currency in result['currencies']:
|
for curr in result['currencies']:
|
||||||
if currency['est_stake'] > 0.0001:
|
if curr['est_stake'] > 0.0001:
|
||||||
curr_output = ("*{currency}:*\n"
|
curr_output = (
|
||||||
"\t`Available: {free: .8f}`\n"
|
f"*{curr['currency']}:*\n"
|
||||||
"\t`Balance: {balance: .8f}`\n"
|
f"\t`Available: {curr['free']:.8f}`\n"
|
||||||
"\t`Pending: {used: .8f}`\n"
|
f"\t`Balance: {curr['balance']:.8f}`\n"
|
||||||
"\t`Est. {stake}: {est_stake: .8f}`\n").format(**currency)
|
f"\t`Pending: {curr['used']:.8f}`\n"
|
||||||
|
f"\t`Est. {curr['stake']}: "
|
||||||
|
f"{round_coin_value(curr['est_stake'], curr['stake'], False)}`\n")
|
||||||
else:
|
else:
|
||||||
curr_output = "*{currency}:* not showing <1$ amount \n".format(**currency)
|
curr_output = "*{currency}:* not showing <1$ amount \n".format(**curr)
|
||||||
|
|
||||||
# Handle overflowing messsage length
|
# Handle overflowing messsage length
|
||||||
if len(output + curr_output) >= MAX_TELEGRAM_MESSAGE_LENGTH:
|
if len(output + curr_output) >= MAX_TELEGRAM_MESSAGE_LENGTH:
|
||||||
@ -512,8 +515,9 @@ class Telegram(RPCHandler):
|
|||||||
output += curr_output
|
output += curr_output
|
||||||
|
|
||||||
output += ("\n*Estimated Value*:\n"
|
output += ("\n*Estimated Value*:\n"
|
||||||
"\t`{stake}: {total: .8f}`\n"
|
f"\t`{result['stake']}: {result['total']: .8f}`\n"
|
||||||
"\t`{symbol}: {value: .2f}`\n").format(**result)
|
f"\t`{result['symbol']}: "
|
||||||
|
f"{round_coin_value(result['value'], result['symbol'], False)}`\n")
|
||||||
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))
|
||||||
|
@ -519,7 +519,7 @@ def test_telegram_balance_handle(default_conf, update, mocker, rpc_balance, tick
|
|||||||
assert '*EUR:*' in result
|
assert '*EUR:*' in result
|
||||||
assert 'Balance:' in result
|
assert 'Balance:' in result
|
||||||
assert 'Est. BTC:' in result
|
assert 'Est. BTC:' in result
|
||||||
assert 'BTC: 12.00000000' in result
|
assert 'BTC: 12.00000000' in result
|
||||||
assert '*XRP:* not showing <1$ amount' in result
|
assert '*XRP:* not showing <1$ amount' in result
|
||||||
|
|
||||||
|
|
||||||
@ -1205,7 +1205,7 @@ def test_send_msg_buy_notification(default_conf, mocker, caplog) -> None:
|
|||||||
'*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, 12.345 USD)`'
|
'*Total:* `(0.00100000 BTC, 12.345 USD)`'
|
||||||
|
|
||||||
freqtradebot.config['telegram']['notification_settings'] = {'buy': 'off'}
|
freqtradebot.config['telegram']['notification_settings'] = {'buy': 'off'}
|
||||||
caplog.clear()
|
caplog.clear()
|
||||||
@ -1389,7 +1389,7 @@ def test_send_msg_buy_notification_no_fiat(default_conf, mocker) -> None:
|
|||||||
'*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.00100000 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:
|
||||||
|
Loading…
Reference in New Issue
Block a user