bugfixing

This commit is contained in:
MuslemRahimi 2025-01-15 16:47:24 +01:00
parent 2c6e38137c
commit d3d2429a74
2 changed files with 23 additions and 19 deletions

View File

@ -50,24 +50,27 @@ async def process_category(cursor, category, condition, category_type='market-ca
res_list = [] res_list = []
for row in raw_data: for row in raw_data:
symbol = row[0] try:
quote_data = await get_quote_data(symbol) symbol = row[0]
if quote_data: quote_data = await get_quote_data(symbol)
item = { if quote_data:
'symbol': symbol, item = {
'name': row[1], 'symbol': symbol,
'price': round(quote_data.get('price'), 2) if quote_data.get('price') is not None else None, 'name': row[1],
'changesPercentage': round(quote_data.get('changesPercentage'), 2) if quote_data.get('changesPercentage') is not None else None, 'price': round(quote_data.get('price'), 2) if quote_data.get('price') is not None else None,
'marketCap': quote_data.get('marketCap', 0), 'changesPercentage': round(quote_data.get('changesPercentage'), 2) if quote_data.get('changesPercentage') is not None else None,
'revenue': 0, 'marketCap': quote_data.get('marketCap', 0),
} 'revenue': 0,
}
# Add screener data if available # Add screener data if available
if symbol in stock_screener_data_dict: if symbol in stock_screener_data_dict:
item['revenue'] = stock_screener_data_dict[symbol].get('revenue',0) item['revenue'] = stock_screener_data_dict[symbol].get('revenue',0)
if item['marketCap'] > 0 and item['revenue'] > 0: if item['marketCap'] > 0 and item['revenue'] > 0:
res_list.append(item) res_list.append(item)
except:
pass
# Sort by market cap and save # Sort by market cap and save
sorted_result = sorted(res_list, key=lambda x: x['marketCap'] if x['marketCap'] else 0, reverse=True) sorted_result = sorted(res_list, key=lambda x: x['marketCap'] if x['marketCap'] else 0, reverse=True)
@ -1176,6 +1179,7 @@ async def run():
#await asyncio.sleep(1) # Small delay between categories #await asyncio.sleep(1) # Small delay between categories
# Process sector categories # Process sector categories
for category, condition in sector_conditions.items(): for category, condition in sector_conditions.items():
await process_category(cursor, category, condition, 'sector') await process_category(cursor, category, condition, 'sector')
#await asyncio.sleep(1) # Small delay between categories #await asyncio.sleep(1) # Small delay between categories

View File

@ -376,7 +376,7 @@ schedule.every().day.at("09:30").do(run_threaded, run_profile).tag('profile_job'
#schedule.every().day.at("10:30").do(run_threaded, run_sec_filings).tag('sec_filings_job') #schedule.every().day.at("10:30").do(run_threaded, run_sec_filings).tag('sec_filings_job')
#schedule.every().day.at("11:00").do(run_threaded, run_executive).tag('executive_job') #schedule.every().day.at("11:00").do(run_threaded, run_executive).tag('executive_job')
schedule.every().day.at("12:00").do(run_threaded, run_market_cap).tag('market_cap_josb') schedule.every().day.at("12:00").do(run_threaded, run_market_cap).tag('market_cap_job')
#schedule.every().day.at("05:00").do(run_threaded, run_implied_volatility).tag('implied_volatility_job') #schedule.every().day.at("05:00").do(run_threaded, run_implied_volatility).tag('implied_volatility_job')