more decimals on the price!

This commit is contained in:
Mike Shultz 2020-03-06 19:18:43 -07:00
parent 5c593255a7
commit 10c6d270bc

7
bot.py
View File

@ -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: if not v:
v = 0 v = 0
return locale.currency(float(v), grouping=True) f = locale.format('%.{}f'.format(decimals), v, grouping=True)
return '${}'.format(f)
class TokenData: class TokenData:
@ -557,7 +558,7 @@ class TelegramMonitorBot:
*Volume(24h)*: {} *Volume(24h)*: {}
@{}""".format( @{}""".format(
monetary_format(pdata.price), monetary_format(pdata.price, decimals=5),
pdata.percent_change, pdata.percent_change,
monetary_format(pdata.market_cap), monetary_format(pdata.market_cap),
monetary_format(pdata.volume), monetary_format(pdata.volume),