This commit is contained in:
MuslemRahimi 2024-08-26 01:20:50 +02:00
parent ae3e47cb2d
commit 35cbff8bbd
2 changed files with 9 additions and 5 deletions

View File

@ -5,11 +5,13 @@ import asyncio
import os
from dotenv import load_dotenv
from datetime import datetime
import re
load_dotenv()
api_key = os.getenv('BENZINGA_API_KEY')
async def get_endpoint(session, symbol):
url = "https://api.benzinga.com/api/v1/bulls_bears_say"
querystring = {"token": api_key, "symbols": symbol}
@ -21,8 +23,10 @@ async def get_endpoint(session, symbol):
for item in res['bulls_say_bears_say']:
date = datetime.fromtimestamp(item['updated'])
date = date.strftime("%B %d, %Y")
formatted_data = {'date': date, 'bearSays': item['bear_case'], 'bullSays': item['bull_case']}
except:
bull_case = item['bull_case']
bear_case = item['bear_case']
formatted_data = {'date': date, 'bullSays': bull_case, 'bearSays': bear_case}
except Exception as e:
formatted_data = {}
except Exception as e:
formatted_data = {}
@ -35,7 +39,7 @@ async def run():
cursor = con.cursor()
cursor.execute("PRAGMA journal_mode = wal")
cursor.execute("SELECT DISTINCT symbol FROM stocks WHERE symbol != ?", ('%5EGSPC',))
cursor.execute("SELECT DISTINCT symbol FROM stocks")
stocks_symbols = [row[0] for row in cursor.fetchall()]
#stocks_symbols = ['NVDA']
con.close()

View File

@ -12,7 +12,7 @@ const twitchAPIKey = process.env.TWITCH_API_KEY;
const twitchSecretKey = process.env.TWITCH_SECRET_KEY;
//const Mixpanel = require('mixpanel');
const UAParser = require('ua-parser-js');
//const UAParser = require('ua-parser-js');
const got = require('got'); //Only version npm i got@11.8.3 works with ESM
const cheerio = require('cheerio');