bugfixing
This commit is contained in:
parent
3f891e3280
commit
8746e1ff42
@ -124,7 +124,7 @@ def get_etf_holding(etf_symbols, etf_con):
|
|||||||
with open(f"json/etf/holding/{ticker}.json", 'wb') as file:
|
with open(f"json/etf/holding/{ticker}.json", 'wb') as file:
|
||||||
file.write(orjson.dumps(res))
|
file.write(orjson.dumps(res))
|
||||||
|
|
||||||
def get_etf_provider(etf_symbols, etf_con):
|
def get_etf_provider(etf_con):
|
||||||
|
|
||||||
|
|
||||||
cursor = etf_con.cursor()
|
cursor = etf_con.cursor()
|
||||||
@ -145,17 +145,8 @@ def get_etf_provider(etf_symbols, etf_con):
|
|||||||
for item in res:
|
for item in res:
|
||||||
try:
|
try:
|
||||||
symbol = item['symbol']
|
symbol = item['symbol']
|
||||||
if symbol in quote_cache:
|
|
||||||
quote_data = quote_cache[symbol]
|
|
||||||
else:
|
|
||||||
# Load the quote data from file if not in cache
|
|
||||||
try:
|
|
||||||
with open(f"json/quote/{symbol}.json") as file:
|
with open(f"json/quote/{symbol}.json") as file:
|
||||||
quote_data = orjson.loads(file.read())
|
quote_data = orjson.loads(file.read())
|
||||||
quote_cache[symbol] = quote_data # Cache the loaded data
|
|
||||||
except:
|
|
||||||
quote_data = None
|
|
||||||
|
|
||||||
# Assign price and changesPercentage if available, otherwise set to None
|
# Assign price and changesPercentage if available, otherwise set to None
|
||||||
item['price'] = round(quote_data.get('price'), 2) if quote_data else None
|
item['price'] = round(quote_data.get('price'), 2) if quote_data else None
|
||||||
item['changesPercentage'] = round(quote_data.get('changesPercentage'), 2) if quote_data else None
|
item['changesPercentage'] = round(quote_data.get('changesPercentage'), 2) if quote_data else None
|
||||||
@ -170,7 +161,8 @@ def get_etf_provider(etf_symbols, etf_con):
|
|||||||
if sorted_res:
|
if sorted_res:
|
||||||
with open(f"json/etf/provider/{provider}.json", 'wb') as file:
|
with open(f"json/etf/provider/{provider}.json", 'wb') as file:
|
||||||
file.write(orjson.dumps(sorted_res))
|
file.write(orjson.dumps(sorted_res))
|
||||||
except:
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
pass
|
pass
|
||||||
cursor.close()
|
cursor.close()
|
||||||
|
|
||||||
@ -224,7 +216,8 @@ async def run():
|
|||||||
|
|
||||||
|
|
||||||
get_etf_holding(etf_symbols, etf_con)
|
get_etf_holding(etf_symbols, etf_con)
|
||||||
get_etf_provider(etf_symbols, etf_con)
|
|
||||||
|
get_etf_provider(etf_con)
|
||||||
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user