This commit is contained in:
MuslemRahimi 2024-10-23 20:15:58 +02:00
parent c58fafe734
commit 3cdb2e3ebe

View File

@ -75,6 +75,7 @@ async def fetch_all_data(session, symbol, time_period):
url = f"https://financialmodelingprep.com/api/v3/historical-chart/{time_period}/{symbol}?serietype=bar&extend=false&from={current_start_date.strftime('%Y-%m-%d')}&to={current_end_date.strftime('%Y-%m-%d')}&apikey={api_key}" url = f"https://financialmodelingprep.com/api/v3/historical-chart/{time_period}/{symbol}?serietype=bar&extend=false&from={current_start_date.strftime('%Y-%m-%d')}&to={current_end_date.strftime('%Y-%m-%d')}&apikey={api_key}"
data = await fetch_data(session, url) data = await fetch_data(session, url)
print("api endpoint called")
if data: if data:
all_data.extend(data) # Accumulate the fetched data all_data.extend(data) # Accumulate the fetched data
@ -119,7 +120,7 @@ async def run():
# List of total symbols to process # List of total symbols to process
total_symbols = stock_symbols # Use stock_symbols + etf_symbols if needed total_symbols = stock_symbols # Use stock_symbols + etf_symbols if needed
chunk_size = len(total_symbols) #// 500 # Divide the list into N chunks chunk_size = len(total_symbols) // 500 # Divide the list into N chunks
chunks = [total_symbols[i:i + chunk_size] for i in range(0, len(total_symbols), chunk_size)] chunks = [total_symbols[i:i + chunk_size] for i in range(0, len(total_symbols), chunk_size)]
for chunk in tqdm(chunks): for chunk in tqdm(chunks):