bugfixing

This commit is contained in:
MuslemRahimi 2025-02-07 23:16:43 +01:00
parent 22bb3f0657
commit d36f24e065
3 changed files with 75 additions and 67 deletions

View File

@ -263,6 +263,7 @@ def get_strike_data():
for symbol in tqdm(total_symbols):
try:
data = aggregate_data_by_strike(symbol)
if len(data) > 0:
for key_element in ['gex','dex']:
val_sums = [item[f"call_{key_element}"] + item[f"put_{key_element}"] for item in data]
threshold = np.percentile(val_sums, 90)
@ -270,8 +271,8 @@ def get_strike_data():
filtered_data = sorted(filtered_data, key=lambda x: x['strike'], reverse=True)
if filtered_data:
save_json(filtered_data, symbol, directory_path+key_element)
except Exception as e:
print(e)
except:
pass
def get_expiry_data():
directory_path = "json/gex-dex/expiry/"
@ -282,6 +283,7 @@ def get_expiry_data():
for symbol in tqdm(total_symbols):
try:
data = aggregate_data_by_expiration(symbol)
if len(data) > 0:
for key_element in ['gex','dex']:
val_sums = [item[f"call_{key_element}"] + item[f"put_{key_element}"] for item in data]
threshold = np.percentile(val_sums, 90)
@ -290,8 +292,8 @@ def get_expiry_data():
if filtered_data:
save_json(filtered_data, symbol, directory_path+key_element)
except Exception as e:
print(e)
except:
pass
if __name__ == '__main__':
get_overview_data()

View File

@ -2695,7 +2695,6 @@ async def get_data(data:GreekExposureData, api_key: str = Security(get_api_key))
media_type="application/json",
headers={"Content-Encoding": "gzip"})
try:
if len(type) > 0:
with open(f"json/gex-dex/{category}/{type}/{ticker}.json", 'rb') as file:

View File

@ -1401,13 +1401,16 @@ async def get_congress_rss_feed(symbols, etf_symbols):
data = data[0] +data[1]
congressional_districts = {"UT": "Utah","CA": "California","NY": "New York","TX": "Texas","FL": "Florida","IL": "Illinois","PA": "Pennsylvania","OH": "Ohio","GA": "Georgia","MI": "Michigan","NC": "North Carolina","AZ": "Arizona","WA": "Washington","CO": "Colorado","OR": "Oregon","VA": "Virginia","NJ": "New Jersey","TN": "Tennessee","MA": "Massachusetts","WI": "Wisconsin","SC": "South Carolina","KY": "Kentucky","LA": "Louisiana","AR": "Arkansas","AL": "Alabama","MS": "Mississippi","NDAL": "North Dakota","SDAL": "South Dakota","MN": "Minnesota","IA": "Iowa","OK": "Oklahoma","ID": "Idaho","NH": "New Hampshire","NE": "Nebraska","MTAL": "Montana","WYAL": "Wyoming","WV": "West Virginia","VTAL": "Vermont","DEAL": "Delaware","RI": "Rhode Island","ME": "Maine","HI": "Hawaii","AKAL": "Alaska","NM": "New Mexico","KS": "Kansas","MS": "Mississippi","CT": "Connecticut","MD": "Maryland","NV": "Nevada",}
res_list = []
for item in data:
try:
ticker = item.get("ticker")
ticker = ticker.replace('BRK.A','BRK-A')
ticker = ticker.replace('BRK/A','BRK-A')
ticker = ticker.replace('BRK.B','BRK-B')
ticker = ticker.replace('BRK/B','BRK-B')
if ticker in symbols or ticker in etf_symbols:
if item['assetDescription'] == 'Bitcoin':
item['ticker'] = 'BTCUSD'
ticker = item.get("ticker")
@ -1432,8 +1435,6 @@ async def get_congress_rss_feed(symbols, etf_symbols):
item["assetType"] = "stock"
elif ticker in etf_symbols:
item["assetType"] = "etf"
else:
item['assetType'] = ''
if 'representative' in item:
item['representative'] = replace_representative(item['representative'])
@ -1448,7 +1449,11 @@ async def get_congress_rss_feed(symbols, etf_symbols):
# Replace 'district' value with the corresponding value from congressional_districts
item['district'] = f"{congressional_districts.get(state_code, state_code)}"
return data
res_list.append(item)
except:
pass
return res_list
@ -1625,6 +1630,10 @@ async def save_json_files():
etf_symbols = [row[0] for row in etf_cursor.fetchall()]
data = await get_congress_rss_feed(symbols, etf_symbols)
with open(f"json/congress-trading/rss-feed/data.json", 'w') as file:
ujson.dump(data, file)
economic_list = await get_economic_calendar()
if len(economic_list) > 0:
with open(f"json/economic-calendar/calendar.json", 'w') as file:
@ -1650,9 +1659,6 @@ async def save_json_files():
ujson.dump(dividends_list, file)
data = await get_congress_rss_feed(symbols, etf_symbols)
with open(f"json/congress-trading/rss-feed/data.json", 'w') as file:
ujson.dump(data, file)
data = await etf_providers(etf_con, etf_symbols)
@ -1660,6 +1666,7 @@ async def save_json_files():
ujson.dump(data, file)
con.close()
etf_con.close()