update cron list
This commit is contained in:
parent
056044355d
commit
4b8d3d52ef
@ -81,8 +81,6 @@ async def process_category(cursor, category, condition, category_type='market-ca
|
|||||||
|
|
||||||
|
|
||||||
async def get_etf_holding(etf_symbols, etf_con):
|
async def get_etf_holding(etf_symbols, etf_con):
|
||||||
etf_symbols = ['AGG']
|
|
||||||
|
|
||||||
for ticker in tqdm(etf_symbols):
|
for ticker in tqdm(etf_symbols):
|
||||||
res = []
|
res = []
|
||||||
df = pd.read_sql_query(query_etf_holding, etf_con, params=(ticker,))
|
df = pd.read_sql_query(query_etf_holding, etf_con, params=(ticker,))
|
||||||
@ -99,27 +97,23 @@ async def get_etf_holding(etf_symbols, etf_con):
|
|||||||
'sharesNumber': item.get('marketValue', None) if not item.get('asset') and item.get('sharesNumber') == 0 else item.get('sharesNumber', None)
|
'sharesNumber': item.get('marketValue', None) if not item.get('asset') and item.get('sharesNumber') == 0 else item.get('sharesNumber', None)
|
||||||
}
|
}
|
||||||
for item in data
|
for item in data
|
||||||
if item.get('marketValue', 0) >= 0 # Exclude items with a negative marketValue
|
if item.get('marketValue', 0) >= 0 and item.get('weightPercentage', 0) > 0 # Exclude items with negative marketValue or non-positive weightPercentage
|
||||||
]
|
]
|
||||||
|
|
||||||
for item in res:
|
for item in res:
|
||||||
try:
|
try:
|
||||||
symbol = item['symbol']
|
symbol = item['symbol']
|
||||||
|
|
||||||
# Check if the symbol data is already in the cache
|
# Adjustments for ticker = 'IBIT'
|
||||||
if symbol in quote_cache:
|
if ticker == 'IBIT' and symbol == 'BTC':
|
||||||
quote_data = quote_cache[symbol]
|
item['symbol'] = 'BTCUSD'
|
||||||
else:
|
item['name'] = 'Bitcoin'
|
||||||
# Load the quote data from file if not in cache
|
|
||||||
try:
|
quote_data = await get_quote_data(item['symbol'])
|
||||||
with open(f"json/quote/{symbol}.json") as file:
|
|
||||||
quote_data = orjson.loads(file.read())
|
|
||||||
quote_cache[symbol] = quote_data # Cache the loaded data
|
|
||||||
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
|
||||||
item['name'] = quote_data.get('name') if quote_data else None
|
item['name'] = quote_data.get('name') if quote_data else item['name']
|
||||||
except:
|
|
||||||
quote_data = None
|
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -138,6 +132,8 @@ async def get_etf_holding(etf_symbols, etf_con):
|
|||||||
file.write(orjson.dumps(final_res))
|
file.write(orjson.dumps(final_res))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async def get_etf_provider(etf_con):
|
async def get_etf_provider(etf_con):
|
||||||
|
|
||||||
cursor = etf_con.cursor()
|
cursor = etf_con.cursor()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user