From 4374934237236dc24f9a9c28513c02df7d1b81fd Mon Sep 17 00:00:00 2001 From: Neythen Date: Sat, 8 May 2021 12:10:05 +0100 Subject: [PATCH] frist section done --- api_caller.py | 112 +++++++++++++++++++++++++++++------- csv/last_update.csv | 2 +- csv/tickers.csv | 42 +++++++------- final.ppm | Bin 460911 -> 486927 bytes resetmatrix.py | 136 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 251 insertions(+), 41 deletions(-) create mode 100644 resetmatrix.py diff --git a/api_caller.py b/api_caller.py index 3a8aad6..86f5236 100644 --- a/api_caller.py +++ b/api_caller.py @@ -5,6 +5,8 @@ import pytz from datetime import datetime import pyEX import datetime as dt +import sys, os, base64, hashlib, hmac +import requests def readCSV(max_stocks): @@ -51,14 +53,16 @@ def updateStockPrices(symbols): try: - #quotes = [finnhubClient.quote(symbol) for symbol in symbols] - #current_prices = [quote['c'] for quote in quotes] - #opening_prices = [quote['o'] for quote in quotes] - quotes = [iexClient.quote(symbol=symbol) for symbol in symbols] + quotes = [finnhubClient.quote(symbol) for symbol in symbols] + current_prices = [quote['c'] for quote in quotes] + opening_prices = [quote['o'] for quote in quotes] + print(current_prices) + print(opening_prices) + + + - current_prices = [quote['iexRealtimePrice'] for quote in quotes] - opening_prices = [quote['iexOpen'] for quote in quotes] print(current_prices, opening_prices) CSV = open('csv/tickers.csv', 'w+') CSV.write('name,current,opening\n') @@ -76,19 +80,81 @@ def updateStockPrices(symbols): print(e) apiCalledError = True + +def updateStockPricesIEX(symbols): + + symbols_str = ','.join(symbols) + method = 'GET' + host = 'https://cloud.iexapis.com/stable' + lastEndpoint = '/tops/last' + querystring = '?symbols=' + symbols_str +'&token='+iexAPIkey + + last_request_url = host + lastEndpoint + querystring + + + print('\nBEGIN REQUEST++++++++++++++++++++++++++++++++++++') + print('Request URL = ' + last_request_url) + last_response = requests.get(last_request_url) + + if last_response.status_code == 200: + print('last success') + + current_prices = [] + for stock in last_response.json(): + current_prices.append(stock['price']) + + + for symbol in symbols: + symbol = 'MSFT' + method = 'GET' + host = 'https://cloud.iexapis.com/stable' + lastEndpoint = '/tops/last' + intradayEndpoint = '/stock/'+ symbol+ '/intraday-prices' + querystring = '?chartIEXOnly=true&token='+iexAPIkey + + intraday_request_url = host + intradayEndpoint + querystring + + print('\nBEGIN REQUEST++++++++++++++++++++++++++++++++++++') + print('Request URL = ' + intraday_request_url) + intraday_response = requests.get(intraday_request_url) + + print('\nRESPONSE++++++++++++++++++++++++++++++++++++') + print('Response code: %d\n' % intraday_response.status_code) + + + print(intraday_response.text) + + for time_point in intraday_response.json(): + print(time_point['date']) + print(time_point['open']) + + + + CSV = open('csv/tickers.csv', 'w+') + CSV.write('name,current,opening\n') + for i, symbol in enumerate(symbols): + + CSV.write(symbol + ',' + str(current_prices[i]) + ',' + str(opening_prices[i]) + '\n') + CSV.close() + + print(lasts) + if __name__ == '__main__': - #finnhubAPIkey = "c24qddqad3ickpckgg80" #Finnhub - #finnhubsandboxAPIkey = "sandbox_c24qddqad3ickpckgg8g" #Finnhub + finnhubAPIkey = "c24qddqad3ickpckgg80" #Finnhub + finnhubsandboxAPIkey = "sandbox_c24qddqad3ickpckgg8g" #Finnhub + sleeptime = 2 #minutes + finnhubClient = finnhub.Client(api_key=finnhubAPIkey) + max_stocks = 200 iexAPIkey = 'pk_68ef6a15902c41f887f0b544a0ca17cf' #IEX iexSandboxAPIkey = 'Tpk_0078dff413ef4f979137f7111452dc4b' + + #updateStockPricesIEX(symbols) - iexClient = pyEX.Client(api_token = iexSandboxAPIkey, version = 'stable') - - print(iexClient.quote(symbol='MSFT')['iexRealtimePrice'] ) - print(iexClient.quote(symbol='MSFT')['iexOpen'] ) - #finnhubClient = finnhub.Client(api_key=APIkey) + + finnhubClient = finnhub.Client(api_key=finnhubAPIkey) + NY_zone = pytz.timezone('America/New_York') NY_time = datetime.now(NY_zone) @@ -97,24 +163,31 @@ if __name__ == '__main__': NY_time = datetime.now(NY_zone) - sleeptime = 2 #minutes - - max_stocks = 200 + print(NY_time) + while True: + NY_time = datetime.now(NY_zone) - symbols, stock_info = readCSV(max_stocks) + if opening < NY_time < closing and datetime.today().weekday() < 5: # we need to do real time updating + print('market open') + - if opening < NY_time < closing: # we need to do real time updating - print('market open') + updateStockPrices(symbols) updateUpdate(NY_time) elif emptyInfo(symbols, stock_info): # if theres any empty stocks + + + updateStockPrices(symbols) updateUpdate(NY_time) else: # update if last update was before the previous days closing + + + f = open('csv/last_update.csv', 'r') CSV = csv.reader(f) last_update_str = next(CSV)[0] @@ -128,6 +201,7 @@ if __name__ == '__main__': print(last_update < yday_closing) if last_update < yday_closing: + updateStockPrices(symbols) updateUpdate(NY_time) diff --git a/csv/last_update.csv b/csv/last_update.csv index 8d1b898..0823154 100644 --- a/csv/last_update.csv +++ b/csv/last_update.csv @@ -1 +1 @@ -07/05/2021 14:25:26 +08/05/2021 07:09:36 diff --git a/csv/tickers.csv b/csv/tickers.csv index 262c3eb..8bf9dc1 100644 --- a/csv/tickers.csv +++ b/csv/tickers.csv @@ -1,22 +1,22 @@ name,current,opening -MSFT,252.64,252.64 -NFLX,502.76,502.76 -GOOG,2402.26,2402.26 -TSLA,669.66,669.66 -AAPL,130.175,130.175 -INTC,57.51,57.51 -TXN,187.09,187.09 -HPQ,35.49,35.49 -HOG,49.53,49.53 -LUV,61.89,61.89 -WMT,140.68,140.68 -BJ,45.675,45.675 -ETSY,164.27,164.27 -G,47.14,47.14 -GDDY,81.14,81.14 -GNRC,324.9,324.9 -PEP,145.53,145.53 -STM,37.26,37.26 -YELP,39.02,39.02 -XRAY,68.69,68.69 -ZTS,172.2,172.2 +MSFT,252.46,252.15 +NFLX,503.84,504.62 +GOOG,2398.69,2400 +TSLA,672.08,665.8 +AAPL,130.21,130.85 +INTC,57.67,57.7 +TXN,187.76,186.7 +HPQ,35.57,34.99 +HOG,49.71,48.96 +LUV,61.66,60.68 +WMT,140.2,141.63 +BJ,45.86,46.59 +ETSY,165.51,163.93 +G,47.13,47.11 +GDDY,81.06,81.78 +GNRC,327.38,319.52 +PEP,145.56,145.23 +STM,37.33,37.31 +YELP,39.46,38.86 +XRAY,68.47,67.39 +ZTS,171.55,169.19 diff --git a/final.ppm b/final.ppm index 47e09259566466b9dc231e812859099e081c990f..89eceed6ff86e6562432757197e74bde25c29350 100755 GIT binary patch delta 22439 zcmch9dwfjS`o5X$y_J(nPBfZ|Mp7XaQbQ`FLLzMlicwTi8k8z2p_J0dMyP6O#?-7{ zs1&E#ax^Km+v1qImAZ}lUE+S1xL=yf?|IkSduI}9d%l1C&V178o_$+uy_aV_@4Mcm zAgj*D$DZ`F$5d}_Ytbw;x>@yR&6`(eUv;xg%vG!TxL&q|IdjfNJ9CyDVxF6F2(y=3 z6fI}3Vz)Tdg)8eQ)g z*RI{ZeftjoT)%$(#EBERqw*~*bg(s&-+kxucHr5k%7nYVMwZZ|`_FQLiG~x(j!~rYT9u1-qv#iDzDWjw`ao+!0dC#%pI}gzH(kfM0uMs|V zo!JFJEX&s?LJS%HgKMY1UTBWgJh+g%43}_&K4fOE>l25u`>pU?>BtA$$Dvj;hq~%9 zOJEGMEs<(wl$LHkQ|4(6W);1*wD^NxOFrBB|MzcWKG$v)7STg~!kKn1jK&$v)O@R- z79Z?06v#0-{Op-C@Vm=Lk8ExiXAV^yoSy$F4fyI+$EYZl6JiP0JX0*K@Khg`{hXBO z^sEXqN9%eF*x2Dkiyvv%>6xn37@9+>eR4+8%=INV@3YC@NS$4al;*ApmJo=kvaam* zcy8Ug_29vSql>fMk#)U$b7J-kbmi)wbfuG1tr=9lD<5TwuK3}x)7MJ_rWDovplHpp z65bD%-^o%R-486+8QWlar%#>QuztN`R4~g*u=+X^{^85q1FYd%VUW)#3(2aI4(?iG34pA8eeuTh)g-C~ z+spSZn0m)-ca*9u>k(_KT=h$fUw(dmVPWBo8#mDE;lqcam>59+l`B_@i;K@}{B`}a z4bA=@95)iLE-WZGdh{r!100JFfcEt1(|^`kfPkNtearGbOcyPqcX$6Ntv$U6Zd2B~ z2$r_o8t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JN%@AFY}{IjI)=aRvkWpxzC7E^)Os@M)(0VN8tuM7JXR`)_dJv@eET^ z@|V6uijF(f(IK6$V%G~GdWJc>41GNzK^*sYODS=^^$q^P0W|BYezeoe_G@MJY8$n9 zcEmXV;bRMo?VFD?cetSJa|XG}`3Z+_&wWFEH$>k$972mJq){Pmr~!f)0w?6T4G;a0 z7n9?sN|wT)K%Sw=oHqs%NPSg(v-e`HgG-eaF+L`l!JT0wxWUESzC++m+$7>#{uvjo zr%}!fdC|#p z72qTQ^!=}Atn;Bn5L}1!R|KS_k&a^U3<#m~+KGO2uI+Wvy)~iwa9#}#zk#po6~j@N z5@$G1(fnq_N~m=Rp+uA%TTp>BjwH_f@WU0k35+8I^E(zH%$WW$$Z*m+=NT4i35-*$HtLdo6xz;(jzDD8A6VTh0aP4)~);%gW|sK2Z1d;BPz=pBBzJ zi|}ij1?xU3(_tP5)D5@`$Hz(N`A;pWrc>6aBYA2`3uJvw^6B#tEo-Wr`$_xMGv4+# z_F2vV*rMoP8RihT_4NcxCHZ>ca!y!>$*-vB!*=I;CSOFw#`@I~o1WVV0-%iBN+Tyb z=V?>06`6L?ft2o;sR`v*KgXWp+#F^#))BCcW-b4YNOyt#pHlU@ezA(K6qaKL^Py_q z#VD6HO?Orq*5VW;z>a&4vw@XTr_%~_S$DVj|qbgp+pCoDYzGpu17Jn0A$fG_!75!dR+{F zkn);5(xPa{Av5Bp1BT!Rj{Lf8oi{P%JPXpqr6vjS=9Ji76u8G(LJ)Yv6a{;Kl&GM8 v+ScsdcCLeilD#zGH&Vy(7q|i_=Y?@v*#YJhfqeHccq>%NZ6c`O25bFak-=3z diff --git a/resetmatrix.py b/resetmatrix.py new file mode 100644 index 0000000..3427779 --- /dev/null +++ b/resetmatrix.py @@ -0,0 +1,136 @@ +#!/usr/bin/python3 + +from __future__ import print_function +from gpiozero import LED +from time import sleep +# 0123456789012345 + +b12a="0111111111111111" +b12b="0111100000111111" +b12c="0111111111111111" +b12d="0111100000111111" + +b12a="0111111111111111" +b12b="0111111111111111" +b12c="0111111111111111" +b12d="0111111111111111" + +b13a="0000000001000000" +b13b="0000000001000000" +b13c="0000000001000000" +b13d="0000000001000000" + +# b12 - 1 adds red tinge +# b12 - 9/8/7/6/5 = 4 bit brightness +# b13 - 9 =1 screen on +# b13 - 6 =1 screen off +xr1=LED(5) +xr2=LED(12) +xg1=LED(13) +xg2=LED(16) +xb1=LED(6) +xb2=LED(23) + +xA=LED(22) +xB=LED(26) +xC=LED(27) +xD=LED(20) + +xLAT=LED(21) +xCLK=LED(17) +xOE=LED(4) + +xCLK.off() + +xOE.off() + +xA.on() +xB.off() +xC.off() +xD.off() + +xr1.off() +xr2.off() +xg1.off() +xg2.off() +xb1.off() +xb2.off() + +b12=b12a +b13=b13a + +for x in range(128): + y=x%16 + if(y==0): + print(' ',end='') + if (b12[y:y+1] is "0"): + print('0',end='') + xr1.off() + xr2.off() + xg1.off() + xg2.off() + xb1.off() + xb2.off() + else: + print('1',end='') + xr1.on() + xr2.on() + xg1.on() + xg2.on() + xb1.on() + xb2.on() + xCLK.on() + sleep(0.001) + xCLK.off() + sleep(0.001) + if(x>31): + b12=b12b + if(x>63): + b12=b12c + if(x>95): + b12=b12d + if(x==(128-12)): + print('*',end='') + xLAT.on() + +xLAT.off(); +print('') + +for x in range(128): + y=x%16 + if(y==0): + print(' ',end='') + if (b13[y:y+1] is "0"): + print('0',end='') + xr1.off() + xr2.off() + xg1.off() + xg2.off() + xb1.off() + xb2.off() + else: + print('1',end='') + xr1.on() + xr2.on() + xg1.on() + xg2.on() + xb1.on() + xb2.on() + xCLK.on() + sleep(0.001) + xCLK.off() + sleep(0.001) + if(x>31): + b13=b13b + if(x>63): + b13=b13c + if(x>95): + b13=b13d + if(x==(128-13)): + print('*',end='') + xLAT.on() + +xLAT.off(); +print('') + +xOE.on();