From fc9850067c1ad12f75122a9496679d72f94e8b16 Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Wed, 19 Mar 2025 10:35:45 +0100 Subject: [PATCH] bugfixing --- app/cron_quote.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/cron_quote.py b/app/cron_quote.py index fe01c52..b9826a5 100755 --- a/app/cron_quote.py +++ b/app/cron_quote.py @@ -38,17 +38,18 @@ async def get_pre_post_quote_of_stocks(ticker_list): ticker_str = ','.join(ticker_list) async with aiohttp.ClientSession() as session: #url = f"https://financialmodelingprep.com/api/v4/batch-pre-post-market/{ticker_str}?apikey={api_key}" - url = f"https://financialmodelingprep.com/api/v4/batch-pre-post-market-trade/{ticker_str}?apikey={api_key}" + url = f"https://financialmodelingprep.com/stable/batch-aftermarket-trade?symbols={ticker_str}&apikey={api_key}" async with session.get(url) as response: if response.status == 200: - return await response.json() + data = await response.json() + return data else: - return {} + return [] async def get_bid_ask_quote_of_stocks(ticker_list): ticker_str = ','.join(ticker_list) async with aiohttp.ClientSession() as session: - url = f"https://financialmodelingprep.com/api/v4/batch-pre-post-market/{ticker_str}?apikey={api_key}" + url = f"https://financialmodelingprep.com/stable/batch-aftermarket-quote?symbols={ticker_str}&apikey={api_key}" async with session.get(url) as response: if response.status == 200: return await response.json() @@ -83,8 +84,8 @@ async def save_bid_ask_as_json(symbol, data): # Update quote data with new price, ask, bid, changesPercentage, and timestamp quote_data.update({ - 'ask': round(data['ask'], 2), # Add ask price - 'bid': round(data['bid'], 2), # Add bid price + 'ask': round(data['askPrice'], 2), # Add ask price + 'bid': round(data['bidPrice'], 2), # Add bid price }) # Save the updated quote data back to the same JSON file