From 10c6d270bc442a101d3da365a978afc5fbc74103 Mon Sep 17 00:00:00 2001 From: Mike Shultz Date: Fri, 6 Mar 2020 19:18:43 -0700 Subject: [PATCH] more decimals on the price! --- bot.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bot.py b/bot.py index d3fe388..0d2a271 100644 --- a/bot.py +++ b/bot.py @@ -89,10 +89,11 @@ def cmc_get_data(jso, cmc_id, pair_symbol='USD'): } -def monetary_format(v): +def monetary_format(v, decimals=2): if not v: v = 0 - return locale.currency(float(v), grouping=True) + f = locale.format('%.{}f'.format(decimals), v, grouping=True) + return '${}'.format(f) class TokenData: @@ -557,7 +558,7 @@ class TelegramMonitorBot: *Volume(24h)*: {} @{}""".format( - monetary_format(pdata.price), + monetary_format(pdata.price, decimals=5), pdata.percent_change, monetary_format(pdata.market_cap), monetary_format(pdata.volume),