optimizing indicator-data

This commit is contained in:
MuslemRahimi 2024-11-20 12:24:04 +01:00
parent a6be85adf0
commit 2a88081505

View File

@ -1169,16 +1169,21 @@ async def get_indicator(data: IndicatorListData, api_key: str = Security(get_api
# Categorize tickers and extract data # Categorize tickers and extract data
for ticker, quote in quote_dict.items(): for ticker, quote in quote_dict.items():
ticker_type = 'stock' # Determine the ticker type based on the sets
if ticker in etf_symbols: ticker_type = (
ticker_type = 'etf' 'etf' if ticker in etf_symbols else
elif ticker in crypto_symbols: 'crypto' if ticker in crypto_symbols else
ticker_type = 'crypto' 'stock'
)
# Filter the quote based on keys in rule_of_list
filtered_quote = {key: quote.get(key) for key in rule_of_list if key in quote} filtered_quote = {key: quote.get(key) for key in rule_of_list if key in quote}
filtered_quote['type'] = ticker_type filtered_quote['type'] = ticker_type
# Add the result to combined_results
combined_results.append(filtered_quote) combined_results.append(filtered_quote)
# Fetch and merge data from stock_screener_data # Fetch and merge data from stock_screener_data
screener_keys = [key for key in rule_of_list if key not in ['volume', 'marketCap', 'changesPercentage', 'price', 'symbol', 'name']] screener_keys = [key for key in rule_of_list if key not in ['volume', 'marketCap', 'changesPercentage', 'price', 'symbol', 'name']]
if screener_keys: if screener_keys: