bugfixing
This commit is contained in:
parent
7627562ddb
commit
a0070ed5f6
@ -1015,10 +1015,10 @@ async def get_economic_calendar():
|
|||||||
ny_tz = pytz.timezone('America/New_York')
|
ny_tz = pytz.timezone('America/New_York')
|
||||||
today = datetime.now(ny_tz)
|
today = datetime.now(ny_tz)
|
||||||
|
|
||||||
start_date = today - timedelta(weeks=2)
|
start_date = today - timedelta(weeks=1)
|
||||||
start_date = start_date - timedelta(days=(start_date.weekday() - 0) % 7)
|
start_date = start_date - timedelta(days=(start_date.weekday() - 0) % 7)
|
||||||
|
|
||||||
end_date = today + timedelta(weeks=2)
|
end_date = today + timedelta(weeks=1)
|
||||||
end_date = end_date + timedelta(days=(4 - end_date.weekday()) % 7)
|
end_date = end_date + timedelta(days=(4 - end_date.weekday()) % 7)
|
||||||
|
|
||||||
url = "https://api.benzinga.com/api/v2.1/calendar/economics"
|
url = "https://api.benzinga.com/api/v2.1/calendar/economics"
|
||||||
@ -1039,7 +1039,7 @@ async def get_economic_calendar():
|
|||||||
try:
|
try:
|
||||||
async with session.get(url, params=querystring, headers=headers) as response:
|
async with session.get(url, params=querystring, headers=headers) as response:
|
||||||
data = ujson.loads(await response.text())['economics']
|
data = ujson.loads(await response.text())['economics']
|
||||||
|
if len(data) > 0:
|
||||||
all_data.extend(data)
|
all_data.extend(data)
|
||||||
print(f"Fetched data for {date_str}: {len(data)} events")
|
print(f"Fetched data for {date_str}: {len(data)} events")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -1061,20 +1061,19 @@ async def get_economic_calendar():
|
|||||||
'country': item['country'],
|
'country': item['country'],
|
||||||
'time': item['time'][0:5],
|
'time': item['time'][0:5],
|
||||||
'date': item['date'],
|
'date': item['date'],
|
||||||
'prior': round(float(item['prior']),2) if item['prior'] != '' else '',
|
'prior': round(float(item['prior']), 2) if item['prior'] != '' else '',
|
||||||
'consensus': round(float(item['consensus'],2)) if item['consensus'] != '' else '',
|
'consensus': round(float(item['consensus']), 2) if item['consensus'] != '' else '',
|
||||||
'actual': round(float(item['actual'],2)) if item['actual'] != '' else '',
|
'actual': round(float(item['actual']), 2) if item['actual'] != '' else '',
|
||||||
'importance': item['importance'],
|
'importance': item['importance'],
|
||||||
'event': item['event_name'],
|
'event': item['event_name'],
|
||||||
})
|
})
|
||||||
except:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
return filtered_data
|
return filtered_data
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async def get_index_list(con,symbols, index_list):
|
async def get_index_list(con,symbols, index_list):
|
||||||
|
|
||||||
async with aiohttp.ClientSession() as session:
|
async with aiohttp.ClientSession() as session:
|
||||||
@ -1773,6 +1772,7 @@ async def save_json_files():
|
|||||||
crypto_symbols = [row[0] for row in crypto_cursor.fetchall()]
|
crypto_symbols = [row[0] for row in crypto_cursor.fetchall()]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
stock_screener_data = await get_stock_screener(con)
|
stock_screener_data = await get_stock_screener(con)
|
||||||
with open(f"json/stock-screener/data.json", 'w') as file:
|
with open(f"json/stock-screener/data.json", 'w') as file:
|
||||||
ujson.dump(stock_screener_data, file)
|
ujson.dump(stock_screener_data, file)
|
||||||
@ -1854,6 +1854,7 @@ async def save_json_files():
|
|||||||
ujson.dump(data, file)
|
ujson.dump(data, file)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
con.close()
|
con.close()
|
||||||
etf_con.close()
|
etf_con.close()
|
||||||
crypto_con.close()
|
crypto_con.close()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user