crypto symbols and logos added

This commit is contained in:
Neythen 2021-05-24 20:59:42 +01:00
parent 160e5fe7d9
commit 8295ca593e
11 changed files with 90 additions and 61 deletions

View File

@ -38,6 +38,39 @@ def readCSV(file_path, max_stocks):
f.close() f.close()
return symbols, stock_info return symbols, stock_info
def readCryptoCSV(file_path, max_stocks):
symbols = []
names = []
stock_info = {}
f = open(file_path, 'r')
CSV = csv.reader(f)
next(CSV)
i = 0
for row in CSV:
print(row)
if i < max_stocks:
i += 1
try:
symbol, name, current_price, opening_price = row
symbols.append(symbol)
names.append(name)
stock_info[name] = [symbol, current_price, opening_price]
except:
symbol = row[0]
name = row[1]
symbols.append(symbol)
names.append(name)
stock_info[name] = [symbol]
else:
print('max stocks exceeded')
break
f.close()
return names, stock_info
def emptyInfo(symbols, stock_info): def emptyInfo(symbols, stock_info):
update = False update = False
@ -137,14 +170,14 @@ def updateStockPricesIEX(symbols):
def updateCrypto(coins): def updateCrypto(coins, coin_info):
response = coingecko_client.get_price(ids=','.join(coins), vs_currencies = 'usd', include_24hr_change=True) response = coingecko_client.get_price(ids=','.join(coins), vs_currencies = 'usd', include_24hr_change=True)
CSV = open('csv/crypto.csv', 'w+') CSV = open('csv/crypto.csv', 'w+')
CSV.write('name,current,24hr change\n') CSV.write('symbol,name,current,24hr change\n')
for coin in coins: for coin in coins:
CSV.write(coin+ ',' + str(response[coin]['usd']) + ',' + str(response[coin]['usd_24h_change']) + '\n') CSV.write(coin_info[coin][0] + ',' + coin+ ',' + str(response[coin]['usd']) + ',' + str(response[coin]['usd_24h_change']) + '\n')
CSV.close() CSV.close()
@ -197,8 +230,10 @@ if __name__ == '__main__':
updateUpdate(NY_time) updateUpdate(NY_time)
while True: while True:
coins, coin_info = readCSV('csv/crypto.csv', max_stocks) coins, coin_info = readCryptoCSV('csv/crypto.csv', max_stocks)
updateCrypto(coins) print(coins)
print(coin_info)
updateCrypto(coins, coin_info)
updateNews() updateNews()

View File

@ -1,3 +1,3 @@
name,current,24hr change symbol,name,current,24hr change
bitcoin,35261,-5.084112872371386 BTC,bitcoin,38402,16.47581759149
ethereum,2108.24,-9.88629261347141 ETH,ethereum,2550.15,29.546988294381478

1 symbol name current 24hr change
2 BTC bitcoin 35261 38402 -5.084112872371386 16.47581759149
3 ETH ethereum 2108.24 2550.15 -9.88629261347141 29.546988294381478

View File

@ -1 +1 @@
23/05/2021 06:28:24 24/05/2021 15:58:28

1 23/05/2021 06:28:24 24/05/2021 15:58:28

View File

@ -1,21 +1,21 @@
headline headline
CBSE 12th Board Exams, JEE Main, NEET 2021 LIVE Updates: Meeting Concludes, Decision to be Out Shortly - News18 UK in race between Covid vaccines and variant, experts warn - The Guardian
Full Flower Moon and lunar eclipse coming May 26 - Barriere Star Journal Up to 8,700 patients died after catching Covid in English hospitals - The Guardian
BBC reporter never wanted to harm Diana - Herald Sun Heysham explosion: Cut gas pipe caused fatal blast, say police - BBC News
Mad man to bad man: Jared Harris on his winning TV streak - The Guardian Buhari orders postponement of FEC, Police Council meeting - Guardian
India battles fatal black fungus threat as coronavirus deaths approach 300,000 - Irish Examiner Explained: Why are doctors prescribing blood thinners to COVID patients? - Times of India
I wasnt going to embarrass him: Waynes blunt answer to Benji question - Fox Sports 'Have you gone bonkers!' Australian ridicules Prince Harry for Archie's first words claim - Express
China's Mars rover starts roaming the Red Planet - Jakarta Post Oilers Josh Archibald suspended one game for clipping Jets Logan Stanley - Sportsnet.ca
YouTube Confirms BTS's “Butter” MV Has Officially Broken All-Time Record For Most Views In 24 Hours - soompi Fire tears through commercial building in downtown New Westminster - CTV News Vancouver
Ireland weather forecast as Met Eireann predicts rollercoaster Sunday but big midweek change ahead - Irish Mirror Airlines are avoiding Belarus after 'state-sponsored hijacking' of Ryanair flight - CNN
Covid: Pfizer and AstraZeneca jabs effective against Indian variant - study - BBC News India vs England series itinerary unlikely to change after ECB-BCCI back-channel talks - Times of India
Delhi Lockdown Extended Again, Arvind Kejriwal Says "May Unlock If..." - NDTV Epic Games Faces Apple in Final Day of Courtroom Battle Over Monopoly Claims - The Wall Street Journal
Rapper AKA gives his version of events leading up to death of fiancé Anele Tembe - News24 Damiano David: Eurovision winner cleared of drug use by broadcaster - BBC News
China says Martian rover takes first drive on surface of Red Planet - TimesLIVE Nova Scotia reports 49 new COVID-19 cases Monday, active total drops to 894 - CTV News Atlantic
300 unvaccinated COVID-19 cases in current outbreak vs 78 vaccinated: Ong Ye Kung - CNA NASA confirms time of Wednesday's super blood moon in Ireland - and where it will be visible to observers - Irish Mirror
Cant allow that: Sneaky AFL star getting away with murder - NEWS.com.au Horror caught on CCTV: Man dies after bike dodges check post in Telangana - Hindustan Times
Millions of Brits unwittingly tracked by phone after Covid jab to see if movements changed... - The Sun Presidency: Southern governors' plan to enforce open grazing ban is of questionable legality - TheCable
India struggles with black fungus infection as Covid deaths surge to 300,000 - The Irish Times Former CDC head urges kids COVID-19 vaccinations as agency probes rare heart issues - Fox News
PM Modi holds meeting on Cyclone Yaas, landfall expected on May 26 - Hindustan Times iOS 14.6 now available with new Apple Podcasts subscriptions - The Verge
Australia Talks, one of the nation's biggest social surveys, is back for 2021. Here's how it works - ABC News Impeachment Witness Gordon Sondland Is Suing Mike Pompeo And U.S. For $1.8 Million - NPR
Bangladesh vs Sri Lanka, 1st ODI in Dhaka: Live Cricket Score and Updates - India Today Blinken Dispatched to Middle East Amid Israel-Gaza Truce - The Wall Street Journal

Can't render this file because it contains an unexpected character in line 12 and column 53.

View File

@ -1,22 +1,4 @@
name,current,opening name,current,opening
MSFT,245.17,247.565 MSFT,250.7,247.785
NFLX,497.89,503.12 NFLX,502.95,501.05
GOOG,2345.1,2365.99 GOOG,2406.68,2367
TSLA,580.88,596.11
AAPL,125.43,127.82
INTC,56.08,56.42
TXN,185.01,186.69
HPQ,31.66,32.26
HOG,48.06,48.68
LUV,60.09,60.26
WMT,141.75,142.52
BJ,45.67,46.26
ETSY,167.56,173
G,44.12,44.3
GDDY,79.08,81.3
GNRC,308.68,311.12
PEP,147.1,147.873
STM,36.21,36.41
YELP,37.92,38.3
XRAY,67.48,68.01
ZTS,176.02,176.55

1 name current opening
2 MSFT 245.17 250.7 247.565 247.785
3 NFLX 497.89 502.95 503.12 501.05
4 GOOG 2345.1 2406.68 2365.99 2367
TSLA 580.88 596.11
AAPL 125.43 127.82
INTC 56.08 56.42
TXN 185.01 186.69
HPQ 31.66 32.26
HOG 48.06 48.68
LUV 60.09 60.26
WMT 141.75 142.52
BJ 45.67 46.26
ETSY 167.56 173
G 44.12 44.3
GDDY 79.08 81.3
GNRC 308.68 311.12
PEP 147.1 147.873
STM 36.21 36.41
YELP 37.92 38.3
XRAY 67.48 68.01
ZTS 176.02 176.55

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
final.ppm

Binary file not shown.

Binary file not shown.

View File

@ -350,13 +350,14 @@ class StockTicker():
#Draw Ticker, current and change onto one image #Draw Ticker, current and change onto one image
def textToImage(self, TICKER, CURRENT, CHANGE, ARROW): def textToImage(self, TICKER, CURRENT, CHANGE, ARROW):
font = ImageFont.load("./fonts/10x20.pil") font = ImageFont.load("./fonts/10x20.pil")
img = Image.new('RGB', (150, 32)) text_width_current, text_height = self.get_text_dimensions(CURRENT, font)
img = Image.new('RGB', (text_width_current + 100, 32))
d = ImageDraw.Draw(img) d = ImageDraw.Draw(img)
d.text((4, 0), TICKER, fill=(255, 255, 255), font=font) d.text((4, 0), TICKER, fill=(255, 255, 255), font=font)
d.text((4, 16), CURRENT, fill=self.greenORred, font=font) d.text((4, 16), CURRENT, fill=self.greenORred, font=font)
text_width_current, text_height = self.get_text_dimensions(CURRENT, font)
img.paste(ARROW, ((text_width_current + 9),18)) img.paste(ARROW, ((text_width_current + 9),18))
d.text(((text_width_current+29), 16), CHANGE, fill=self.greenORred, font=font) d.text(((text_width_current+29), 16), CHANGE, fill=self.greenORred, font=font)
@ -427,9 +428,9 @@ class StockTicker():
for i, coin in enumerate(self.coins): for i, coin in enumerate(self.coins):
info = self.coin_info[coin] info = self.coin_info[coin]
change = float(info[1]) #TEXT change = float(info[2]) #TEXT
ticker = coin.upper() #TEXT ticker = info[0] #TEXT
current = '%.2f' % float(info[0]) #TEXT current = '%.2f' % float(info[1]) #TEXT
@ -439,7 +440,7 @@ class StockTicker():
try: try:
logos_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos') logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'crypto')
logo = Image.open(os.path.join(logos_path, ticker + '.png')) logo = Image.open(os.path.join(logos_path, ticker + '.png'))
stitchedStock = self.stitchImage([logo,midFrame]) stitchedStock = self.stitchImage([logo,midFrame])
@ -495,15 +496,18 @@ class StockTicker():
for row in CSV: for row in CSV:
try: try:
coin, current_price, day_change = row symbol, coin, current_price, day_change = row
self.coins.append(coin) self.coins.append(coin)
self.coin_info[coin] = [current_price, day_change] self.coin_info[coin] = [symbol, current_price, day_change]
except: except:
symbol = row[0] symbol = row[0]
coin = row[1]
self.coins.append(coin) self.coins.append(coin)
self.coin_info[coin] = [] self.coin_info[coin] = [symbol]
f.close() f.close()
#Main run definition called by server #Main run definition called by server
def runStockTicker(self, runtime, delay, speedtime): def runStockTicker(self, runtime, delay, speedtime):
@ -586,8 +590,9 @@ if __name__ == '__main__':
#print(sys.stdin.readlines()) #print(sys.stdin.readlines())
stock_ticker = StockTicker() stock_ticker = StockTicker()
#stock_ticker.readCSV()
#stock_ticker.displayUserText() #stock_ticker.displayUserText()
#stock_ticker.process_msg('f') #
#stock_ticker.displayNews() #stock_ticker.displayNews()
#stock_ticker.displayGIF('/home/pi/Desktop/stock_ticker/gifs/open.gif') #stock_ticker.displayGIF('/home/pi/Desktop/stock_ticker/gifs/open.gif')
@ -601,6 +606,7 @@ if __name__ == '__main__':
#stock_ticker.displayText() #stock_ticker.displayText()
#stock_ticker.getFullStockImage(1) #stock_ticker.getFullStockImage(1)
#stock_ticker.process_msg('f')
#stock_ticker.displayStocks() #stock_ticker.displayStocks()
#stock_ticker.delay = 0.001 #stock_ticker.delay = 0.001

View File

@ -14,7 +14,13 @@ import pexpect
from pycoingecko import CoinGeckoAPI from pycoingecko import CoinGeckoAPI
if __name__ == '__main__': if __name__ == '__main__':
coingecko_client = CoinGeckoAPI()
response = coingecko_client.get_coin_by_id(id='bitcoin')
#response = coingecko_client.get_ticker(ids='bitcoin', vs_currencies = 'usd', include_24hr_change=True)
print(response)
#print(dir( coingecko_client))
#print(dir( coingecko_client))