bugfixing industry

This commit is contained in:
MuslemRahimi 2024-11-11 10:59:59 +01:00
parent aa442a9238
commit 5e91bd45a0

View File

@ -18,14 +18,15 @@ with open(f"json/stock-screener/data.json", 'rb') as file:
stock_screener_data = orjson.loads(file.read())
def format_filename(industry_name):
# Replace spaces with hyphens
formatted_name = industry_name.replace(' ', '-')
# Replace spaces and slashes with hyphens
formatted_name = industry_name.replace(' ', '-').replace('/', '-')
# Replace "&" with "and"
formatted_name = formatted_name.replace('&', 'and')
# Remove any extra hyphens (e.g., from consecutive spaces)
formatted_name = re.sub(r'-+', '-', formatted_name)
# Convert to lowercase for consistency
return formatted_name.lower()
formatted_name = formatted_name.lower()
return formatted_name
date, _ = GetStartEndDate().run()
@ -104,6 +105,7 @@ async def run():
full_industry_list = get_each_industry_data()
for industry, stocks in full_industry_list.items():
filename = 'industries/'+format_filename(industry)
stocks = [item for item in stocks if item.get('marketCap') is not None and item['marketCap'] > 0]
stocks = sorted(stocks, key=lambda x: x['marketCap'], reverse=True)
history_list = []
for item in historical_pe_list: