prepost
This commit is contained in:
parent
bece376294
commit
f569f9ed1e
@ -1861,8 +1861,18 @@ class StockTicker():
|
||||
except:
|
||||
pass
|
||||
|
||||
if all_stocks_settings['prepost']:
|
||||
try:
|
||||
f = open('csv/prepost_settings.json', 'r')
|
||||
prepost_settings = json.load(f)
|
||||
f.close()
|
||||
except:
|
||||
pass
|
||||
|
||||
stock_info = all_stocks_settings['symbols']
|
||||
symbols = list(stock_info.keys())
|
||||
timenow = datetime.now(ny_zone).replace(tzinfo=None).strftime("%H:%M:%S")
|
||||
weekday = datetime.now(ny_zone).replace(tzinfo=None).weekday()
|
||||
|
||||
for i, symbol in enumerate(symbols):
|
||||
|
||||
@ -1897,7 +1907,74 @@ class StockTicker():
|
||||
stitchedStock = midFrame
|
||||
else:
|
||||
stitchedStock = midFrame
|
||||
|
||||
|
||||
try:
|
||||
if all_stocks_settings['prepost']:
|
||||
font = ImageFont.load("./fonts/6x13.pil")
|
||||
time_font = ImageFont.load("./fonts/5x8.pil")
|
||||
prepost_time = prepost_settings[symbol]['time_now']
|
||||
|
||||
if ((timenow < "09:30:00" and timenow > "04:00:00") and (weekday <= 4)): #premarket
|
||||
try:
|
||||
preprice = '%.2f' % abs(float(prepost_settings[symbol]['Pre-market']['preprice']))
|
||||
prechange = '%.2f' % abs(float(prepost_settings[symbol]['Pre-market']['prechange']))
|
||||
prepercent = '%.2f' % abs(float(prepost_settings[symbol]['Pre-market']['prepercent']))
|
||||
|
||||
premkt_img = self.textImage('Pre-Market', font, r=255, g=255, b=0)
|
||||
if '-' in prepost_settings[symbol]['Pre-market']['prechange']:
|
||||
preprice_img = self.textImage(preprice, font, r = 255, g = 0 , b = 0)
|
||||
prechange_img = self.textImage(prechange, font, r = 255, g = 0, b = 0)
|
||||
prepercent_img = self.textImage('('+prepercent + '%' + ')' + timenow + str(weekday), font, r=255, g=0, b=0)
|
||||
arrow = Image.open('logos/down-tiny.png')
|
||||
else:
|
||||
preprice_img = self.textImage(preprice, font, r = 0, g = 255 , b = 0)
|
||||
prechange_img = self.textImage(prechange, font, r = 0, g = 255, b = 0)
|
||||
prepercent_img = self.textImage('('+prepercent + '%' + ')' + timenow + str(weekday), font, r=0, g=255, b=0)
|
||||
arrow = Image.open('logos/up-tiny.png')
|
||||
time_img = self.textImage(prepost_time, time_font, r=255,g=255,b=255)
|
||||
|
||||
prepost_img = Image.new('RGB', (10 + max(premkt_img.size[0] + prepercent_img.size[0], preprice_img.size[0] + 3 + prechange_img.size[0] + arrow.size[0]),32))
|
||||
prepost_img.paste(premkt_img, (0,0))
|
||||
prepost_img.paste(prepercent_img, (premkt_img.size[0], 1))
|
||||
prepost_img.paste(preprice_img,(0,12))
|
||||
prepost_img.paste(time_img, (0, 24))
|
||||
prepost_img.paste(arrow, (preprice_img.size[0],18))
|
||||
prepost_img.paste(prechange_img, (preprice_img.size[0] + arrow.size[0] + 3,12))
|
||||
except:
|
||||
pass
|
||||
|
||||
elif ((timenow < "04:00:00" or timenow > "16:00:00") and (weekday <= 4)): #postmarket
|
||||
try:
|
||||
postprice = '%.2f' % abs(float(prepost_settings[symbol]['Post-market']['postprice']))
|
||||
postchange = '%.2f' % abs(float(prepost_settings[symbol]['Post-market']['postchange']))
|
||||
postpercent = '%.2f' % abs(float(prepost_settings[symbol]['Post-market']['postpercent']))
|
||||
|
||||
postmkt_img = self.textImage('After-Hours', font, r=255, g=255, b=0)
|
||||
if '-' in prepost_settings[symbol]['Post-market']['postchange']:
|
||||
postprice_img = self.textImage(postprice, font, r = 255, g = 0, b = 0)
|
||||
postchange_img = self.textImage(postchange, font, r = 255, g = 0, b = 0)
|
||||
postpercent_img = self.textImage('('+postpercent +'%'+')' + timenow + str(weekday), font, r=255, g=0, b=0)
|
||||
arrow = Image.open('logos/down-tiny.png')
|
||||
else:
|
||||
postprice_img = self.textImage(postprice, font, r =0, g = 255 , b = 0)
|
||||
postchange_img = self.textImage(postchange, font, r = 0, g = 255, b = 0)
|
||||
postpercent_img = self.textImage('(' + postpercent + '%'+')' + timenow + str(weekday), font, r=0, g=255, b=0)
|
||||
arrow = Image.open('logos/up-tiny.png')
|
||||
time_img = self.textImage(prepost_time, time_font, r=255,g=255,b=255)
|
||||
|
||||
prepost_img = Image.new('RGB', (10 + max(postmkt_img.size[0] + postpercent_img.size[0], postprice_img.size[0] + 3 + postchange_img.size[0] + arrow.size[0]) , 32))
|
||||
prepost_img.paste(postmkt_img, (0,0))
|
||||
prepost_img.paste(postpercent_img, (postmkt_img.size[0], 1))
|
||||
prepost_img.paste(postprice_img,(0,12))
|
||||
prepost_img.paste(time_img, (0, 24))
|
||||
prepost_img.paste(arrow, (postprice_img.size[0],18))
|
||||
prepost_img.paste(postchange_img, (postprice_img.size[0] + arrow.size[0] + 3,12))
|
||||
except:
|
||||
pass
|
||||
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
if all_stocks_settings['chart'] and (symbol in portfolio_settings): #IF USER INPUTTED PORTFOLIO SETTINGS, DISPLAY PORTFOLIO INFO
|
||||
try:
|
||||
@ -1924,7 +2001,6 @@ class StockTicker():
|
||||
else:
|
||||
pnlpercent2_img = self.textImage(str('%.2f' % abs(pnlpercent)) + '%', font, r = 255, g = 0, b = 0)
|
||||
|
||||
|
||||
daypercent_img = self.textImage('Day%', font, r = 255, g = 255 , b = 255)
|
||||
if float(info['percent_change']) >= 0:
|
||||
daypercent2_img = self.textImage(str('%.2f' % abs(float(info['percent_change']))) +'%', font, r = 0, g = 255, b = 0)
|
||||
@ -1983,6 +2059,16 @@ class StockTicker():
|
||||
pass
|
||||
|
||||
image_list.append(stitchedStock)
|
||||
|
||||
try:
|
||||
if all_stocks_settings['prepost']:
|
||||
try:
|
||||
image_list.append(prepost_img)
|
||||
except:
|
||||
pass
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
if all_stocks_settings['chart'] and (symbol in portfolio_settings):
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user