update cron job stock deck
This commit is contained in:
parent
6532b08024
commit
dbfd50a25c
@ -50,6 +50,12 @@ async def get_data(ticker):
|
|||||||
except:
|
except:
|
||||||
company_quote = {}
|
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:
|
if data['esg_data'] == None:
|
||||||
company_esg_score = {'ESGScore': 'n/a', 'socialScore': 'n/a', 'environmentalScore': 'n/a', 'governanceScore': 'n/a'}
|
company_esg_score = {'ESGScore': 'n/a', 'socialScore': 'n/a', 'environmentalScore': 'n/a', 'governanceScore': 'n/a'}
|
||||||
company_esg_rating = {'ESGRiskRating': 'n/a', 'industry': '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'],
|
'ceoName': company_profile[0]['ceo'],
|
||||||
'companyName': company_profile[0]['companyName'],
|
'companyName': company_profile[0]['companyName'],
|
||||||
'industry': company_profile[0]['industry'],
|
'industry': company_profile[0]['industry'],
|
||||||
'image': company_profile[0]['image'],
|
|
||||||
'sector': company_profile[0]['sector'],
|
'sector': company_profile[0]['sector'],
|
||||||
'beta': company_profile[0]['beta'],
|
'beta': company_profile[0]['beta'],
|
||||||
'marketCap': company_profile[0]['mktCap'],
|
'marketCap': company_profile[0]['mktCap'],
|
||||||
@ -78,6 +83,10 @@ async def get_data(ticker):
|
|||||||
'country': company_profile[0]['country'],
|
'country': company_profile[0]['country'],
|
||||||
'exchange': company_profile[0]['exchangeShortName'],
|
'exchange': company_profile[0]['exchangeShortName'],
|
||||||
'earning': company_quote['earningsAnnouncement'],
|
'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.
|
'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'],
|
'website': company_profile[0]['website'],
|
||||||
'description': company_profile[0]['description'],
|
'description': company_profile[0]['description'],
|
||||||
@ -116,7 +125,7 @@ async def run():
|
|||||||
cursor.execute("PRAGMA journal_mode = wal")
|
cursor.execute("PRAGMA journal_mode = wal")
|
||||||
cursor.execute("SELECT DISTINCT symbol FROM stocks")
|
cursor.execute("SELECT DISTINCT symbol FROM stocks")
|
||||||
stocks_symbols = [row[0] for row in cursor.fetchall()]
|
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)
|
res = await get_data(ticker)
|
||||||
await save_stockdeck(ticker, [res])
|
await save_stockdeck(ticker, [res])
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@ -66,11 +66,12 @@ class PricePredictor:
|
|||||||
|
|
||||||
#Test Mode
|
#Test Mode
|
||||||
async def main():
|
async def main():
|
||||||
for ticker in ['TSLA']:
|
for ticker in ['NVDA']:
|
||||||
start_date = datetime(2000, 1, 1).strftime("%Y-%m-%d")
|
start_date = datetime(2000, 1, 1).strftime("%Y-%m-%d")
|
||||||
end_date = datetime.today().strftime("%Y-%m-%d")
|
end_date = datetime.today().strftime("%Y-%m-%d")
|
||||||
df = await download_data(ticker, start_date, end_date)
|
df = await download_data(ticker, start_date, end_date)
|
||||||
data = PricePredictor().run(df)
|
data = PricePredictor().run(df)
|
||||||
|
print(data)
|
||||||
|
|
||||||
# Run the main function
|
# Run the main function
|
||||||
#asyncio.run(main())
|
#asyncio.run(main())
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user