From b896914edf2ec6ece8a9790a92c1e9bc3df75063 Mon Sep 17 00:00:00 2001 From: Neythen Treloar Date: Sun, 6 Mar 2022 18:36:03 +0000 Subject: [PATCH] 2dp for percent change --- server.py | 5 +++-- stockTicker.py | 24 +++++++++++++----------- templates/index.html | 10 ++++++++++ 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/server.py b/server.py index d1d21d9..88f5f43 100755 --- a/server.py +++ b/server.py @@ -29,8 +29,8 @@ import sys #api_caller = pexpect.spawn("sudo -E taskset -c 3 python3 api_caller.py") -api_caller = pexpect.spawn("sudo -E taskset -c 3 python3 database_caller.py") -time.sleep(3) +#api_caller = pexpect.spawn("sudo -E taskset -c 3 python3 database_caller.py") +#time.sleep(3) #api_caller.sendline('A') @@ -558,6 +558,7 @@ def save_trade_settings(input_settings): filename = input_settings['feature'].lower() + '_settings.json' f = open('csv/' + filename, 'r') current_settings = json.load(f) + print(current_settings) f.close() current_settings['speed'] = input_settings['speed'].lower() diff --git a/stockTicker.py b/stockTicker.py index e49c791..7bcde7c 100755 --- a/stockTicker.py +++ b/stockTicker.py @@ -935,7 +935,7 @@ class StockTicker(): arrow, change = self.getArrow(point_change) - percent_change = str(abs(percent_change)) + '%' + percent_change = '%.2f' % abs(percent_change) + '%' point_change = str(abs(point_change)) current = str(current) @@ -1010,10 +1010,10 @@ class StockTicker(): if all_crypto_settings["percent"]: # convert percent to points - change = str(abs(float(coin_info[cb]['percent_change']))) + '%' + change = '%.2f' % abs(float(coin_info[cb]['percent_change'])) + '%' else: - change = str(abs(float(change))) + change = str(abs(change)) current = str(current) midFrame = self.textToImageProf(ticker + '(' + base + ')', current, change, arrow, font=ImageFont.load("./fonts/6x10.pil")) #IMAGE THE TEXT @@ -1072,7 +1072,7 @@ class StockTicker(): current = float(forex_settings[sb]['current']) change = float(forex_settings[sb]['24hr_change']) - percent_change = str(abs(float(forex_settings[sb]['percent_change']))) +'%' + percent_change = '%.2f' % abs(float(forex_settings[sb]['percent_change'])) +'%' point_change = str(abs(change)) @@ -1163,12 +1163,14 @@ class StockTicker(): if all_forex_settings["percent"]: - # convert percent to points + change = abs(float(forex_settings[sb]['percent_change'])) - change = str(change) + '%' + + + change = '%.2f' % change + '%' else: - change = str(change) + change = str(abs(change)) current = str(current) midFrame = self.textToImageProf(symbol + '(' + base + ')', current, change, arrow, font = ImageFont.load("./fonts/6x10.pil")) #IMAGE THE TEXT @@ -1243,11 +1245,11 @@ class StockTicker(): arrow, change = self.getArrow(change) percent_change = '%.2f' % abs(float(info['percent_change'])) + '%' - point_change = '%.2f' % abs(change) + point_change = str(abs(change)) print(percent_change, point_change) - current = '%.2f' % float(info['current']) #TEXT + current = str(float(info['current'])) #TEXT @@ -1327,10 +1329,10 @@ class StockTicker(): if all_stocks_settings["percent"]: change = '%.2f' % abs(float(info['percent_change'])) + '%' else: - change = '%.2f' % abs(change) + change = str(abs(change)) - current = '%.2f' % float(info['current']) #TEXT + current = str(float(info['current'])) #TEXT midFrame = self.textToImageProf(ticker, current, change, arrow, font=ImageFont.load("./fonts/6x10.pil")) #IMAGE THE TEXT if all_stocks_settings['logos']: diff --git a/templates/index.html b/templates/index.html index 6677d02..62a57b1 100644 --- a/templates/index.html +++ b/templates/index.html @@ -3214,6 +3214,16 @@ value="" id="flexCheckChecked31" + + {% + + if + + news_settings.title%} + + checked + + {%endif%} />