update bulls bear say
This commit is contained in:
parent
eddfc85c1d
commit
a50ae8e5f3
@ -15,31 +15,32 @@ api_key = os.getenv('BENZINGA_API_KEY')
|
|||||||
async def get_endpoint(session, symbol):
|
async def get_endpoint(session, symbol):
|
||||||
url = "https://api.benzinga.com/api/v1/bulls_bears_say"
|
url = "https://api.benzinga.com/api/v1/bulls_bears_say"
|
||||||
querystring = {"token": api_key, "symbols": symbol}
|
querystring = {"token": api_key, "symbols": symbol}
|
||||||
|
formatted_data = {}
|
||||||
try:
|
try:
|
||||||
async with session.get(url, params=querystring) as response:
|
async with session.get(url, params=querystring) as response:
|
||||||
res = ujson.loads(await response.text())
|
res = ujson.loads(await response.text())
|
||||||
try:
|
try:
|
||||||
for item in res['bulls_say_bears_say']:
|
for item in res['bulls_say_bears_say']:
|
||||||
date = datetime.fromtimestamp(item['updated'])
|
date = datetime.fromtimestamp(item['updated'])
|
||||||
date = date.strftime("%B %d, %Y")
|
date = date.strftime("%Y-%m-%d %H:%M:%S")
|
||||||
bull_case = item['bull_case']
|
bull_case = item['bull_case']
|
||||||
bear_case = item['bear_case']
|
bear_case = item['bear_case']
|
||||||
formatted_data = {'date': date, 'bullSays': bull_case, 'bearSays': bear_case}
|
formatted_data = {'date': date, 'bullSays': bull_case, 'bearSays': bear_case}
|
||||||
except Exception as e:
|
except:
|
||||||
formatted_data = {}
|
pass
|
||||||
except Exception as e:
|
except:
|
||||||
formatted_data = {}
|
pass
|
||||||
print(e)
|
|
||||||
with open(f"json/bull_bear_say/{symbol}.json", 'w') as file:
|
if formatted_data:
|
||||||
ujson.dump(formatted_data, file)
|
with open(f"json/bull_bear_say/{symbol}.json", 'w') as file:
|
||||||
|
ujson.dump(formatted_data, file)
|
||||||
|
|
||||||
async def run():
|
async def run():
|
||||||
con = sqlite3.connect('stocks.db')
|
con = sqlite3.connect('stocks.db')
|
||||||
|
|
||||||
cursor = con.cursor()
|
cursor = con.cursor()
|
||||||
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 WHERE symbol NOT LIKE '%.%'")
|
||||||
stocks_symbols = [row[0] for row in cursor.fetchall()]
|
stocks_symbols = [row[0] for row in cursor.fetchall()]
|
||||||
#stocks_symbols = ['NVDA']
|
#stocks_symbols = ['NVDA']
|
||||||
con.close()
|
con.close()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user