From dbfd50a25cb86f1537fbbf5a3a750d5bafb624ef Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Mon, 26 Aug 2024 20:13:00 +0200 Subject: [PATCH] update cron job stock deck --- app/cron_stockdeck.py | 13 +++++++++++-- .../__pycache__/prophet_model.cpython-310.pyc | Bin 2732 -> 2747 bytes app/ml_models/prophet_model.py | 3 ++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/cron_stockdeck.py b/app/cron_stockdeck.py index 28762f0..7c1bdc7 100755 --- a/app/cron_stockdeck.py +++ b/app/cron_stockdeck.py @@ -50,6 +50,12 @@ async def get_data(ticker): except: company_quote = {} + try: + with open(f"json/forward-pe/{ticker}.json", 'r') as file: + forward_pe = ujson.load(file)['forwardPE'] + except: + forward_pe = None + if data['esg_data'] == None: company_esg_score = {'ESGScore': 'n/a', 'socialScore': 'n/a', 'environmentalScore': 'n/a', 'governanceScore': 'n/a'} company_esg_rating = {'ESGRiskRating': 'n/a', 'industry': 'n/a'} @@ -70,7 +76,6 @@ async def get_data(ticker): 'ceoName': company_profile[0]['ceo'], 'companyName': company_profile[0]['companyName'], 'industry': company_profile[0]['industry'], - 'image': company_profile[0]['image'], 'sector': company_profile[0]['sector'], 'beta': company_profile[0]['beta'], 'marketCap': company_profile[0]['mktCap'], @@ -78,6 +83,10 @@ async def get_data(ticker): 'country': company_profile[0]['country'], 'exchange': company_profile[0]['exchangeShortName'], 'earning': company_quote['earningsAnnouncement'], + 'pe': company_quote['pe'], + 'eps': company_quote['eps'], + 'sharesOutstanding': company_quote['sharesOutstanding'], + 'forwardPE': forward_pe, 'previousClose': company_quote['price'], #This is true because I update my db before the market opens hence the price will be the previousClose price. 'website': company_profile[0]['website'], 'description': company_profile[0]['description'], @@ -116,7 +125,7 @@ async def run(): cursor.execute("PRAGMA journal_mode = wal") cursor.execute("SELECT DISTINCT symbol FROM stocks") stocks_symbols = [row[0] for row in cursor.fetchall()] - for ticker in stocks_symbols: + for ticker in tqdm(stocks_symbols): res = await get_data(ticker) await save_stockdeck(ticker, [res]) diff --git a/app/ml_models/__pycache__/prophet_model.cpython-310.pyc b/app/ml_models/__pycache__/prophet_model.cpython-310.pyc index c3773a9bf164b8dace41914b120b1243a6a9cf73..5af84d45c71e9b23d463b1029f715d8b478587a0 100644 GIT binary patch delta 120 zcmZ1@x?7YtpO=@50SNYPIFq({Bd;(gPZ*Hb$e6tAwqFrJ0eDp^!O+ zA(%mv)lZZ07K>k)i(}>mb_RwbZJ_!hQy`(qKDm!mfvHGr@@h^?5dokGQv(O15F;ND R^DuHTvizR>jdLp_KLA+Y8BhQK delta 107 zcmdljx<-^YpO=@50SH$7nVU9mBd;(gj~|fN$e6sgOB^A(%mv)lZZ0 z7E4I5k7MQqb_RwbZJ@d$Qy`(qHhCJS!sOkYWGE>i;sqYxt>7_