SomberNight 7 years ago
parent
commit
64fa7dd6c3
  1. 7
      lib/exchange_rate.py

7
lib/exchange_rate.py

@ -5,6 +5,7 @@ import sys
from threading import Thread from threading import Thread
import time import time
import csv import csv
import decimal
from decimal import Decimal from decimal import Decimal
from .bitcoin import COIN from .bitcoin import COIN
@ -389,7 +390,11 @@ class FxThread(ThreadJob):
def ccy_amount_str(self, amount, commas): def ccy_amount_str(self, amount, commas):
prec = CCY_PRECISIONS.get(self.ccy, 2) prec = CCY_PRECISIONS.get(self.ccy, 2)
fmt_str = "{:%s.%df}" % ("," if commas else "", max(0, prec)) fmt_str = "{:%s.%df}" % ("," if commas else "", max(0, prec))
return fmt_str.format(round(amount, prec)) try:
rounded_amount = round(amount, prec)
except decimal.InvalidOperation:
rounded_amount = amount
return fmt_str.format(rounded_amount)
def run(self): def run(self):
# This runs from the plugins thread which catches exceptions # This runs from the plugins thread which catches exceptions

Loading…
Cancel
Save