bugfixing

This commit is contained in:
MuslemRahimi 2024-12-12 14:53:33 +01:00
parent 410db5436a
commit 1da373e967

View File

@ -1292,11 +1292,22 @@ async def process_watchlist_ticker(ticker, rule_of_list, quote_keys_to_include,
# Merge with screener data, but only for fields not in quote_dict # Merge with screener data, but only for fields not in quote_dict
symbol = filtered_quote.get('symbol') symbol = filtered_quote.get('symbol')
if symbol and symbol in screener_dict: if symbol:
# Exclude price, volume, and changesPercentage from screener_dict update # Ensure symbol exists in screener_dict, create if not
screener_dict.setdefault(symbol, {})
# Exclude 'price', 'volume', and 'changesPercentage' from screener_dict update
for key in ['price', 'volume', 'changesPercentage']: for key in ['price', 'volume', 'changesPercentage']:
screener_dict[symbol].pop(key, None) screener_dict[symbol].pop(key, None)
filtered_quote.update(screener_dict[symbol])
# Update filtered_quote with screener_dict data or set to None if key is missing
for key, value in screener_dict[symbol].items():
filtered_quote[key] = value
# Ensure keys in screener_dict are present in filtered_quote, set to None if missing
for key in screener_dict.get(symbol, {}):
filtered_quote.setdefault(key, None)
result = filtered_quote result = filtered_quote
@ -1381,7 +1392,7 @@ async def get_watchlist(data: GetWatchList, api_key: str = Security(get_api_key)
} }
compressed_data = gzip.compress(orjson.dumps(res)) compressed_data = gzip.compress(orjson.dumps(res))
return StreamingResponse( return StreamingResponse(
io.BytesIO(compressed_data), io.BytesIO(compressed_data),
media_type="application/json", media_type="application/json",