fixed removing trailing zeros for commodities

This commit is contained in:
Justin 2023-05-03 12:14:14 +08:00 committed by GitHub
parent e50eb8caf5
commit 2534f18495
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1501,14 +1501,19 @@ class StockTicker():
point_change2 = abs(change)
point_changefinal = '{0:.10f}'.format(point_change2).rstrip("0")
point_change = str(point_changefinal)
num3 = point_changefinal.split('.')
if len(num3[1]) <= 1:
point_change = '%.2f' % float(point_changefinal)
else:
point_change = str(point_changefinal)
current = float(info["current"])
current_final = '{0:.10f}'.format(current).rstrip("0")
current = str(current_final)
num2 = current_final.split('.')
if len(num2[1]) <= 1:
current = '%.2f' % float(current_final)
else:
current = str(current_final)
if not all_commodities_settings['percent']:
percent_change = False
@ -1583,9 +1588,7 @@ class StockTicker():
change = float(info['24hr_change']) #TEXT
unit = info['unit']
ticker = symbol + '(' + unit + ')' #TEXT
arrow, change = self.getArrow(change, professional=True)
if all_commodities_settings["percent"]:
@ -1593,12 +1596,19 @@ class StockTicker():
else:
point_change2 = abs(change)
point_changefinal = '{0:.10f}'.format(point_change2).rstrip("0")
change = str(point_changefinal)
num3 = point_changefinal.split('.')
if len(num3[1]) <= 1:
change = '%.2f' % float(point_changefinal)
else:
change = str(point_changefinal)
current = float(info["current"])
current_final = '{0:.10f}'.format(current).rstrip("0")
current = str(current_final)
num2 = current_final.split('.')
if len(num2[1]) <= 1:
current = '%.2f' % float(current_final)
else:
current = str(current_final)
midFrame = self.textToImageProf(ticker, current, change, arrow, font=ImageFont.load("./fonts/6x10.pil")) #IMAGE THE TEXT