update screener

This commit is contained in:
MuslemRahimi 2024-11-19 18:18:07 +01:00
parent 32ce0e4565
commit eadf75f84c

View File

@ -72,13 +72,17 @@ def calculate_price_changes(symbol, item, con):
if not data.empty:
past_price = data.iloc[0]['close']
current_price = item['price']
item[name] = round(((current_price - past_price) / past_price) * 100, 2)
change = round(((current_price - past_price) / past_price) * 100, 2)
# Set item[name] to None if the change is -100
item[name] = None if change == -100 else change
except:
# Handle exceptions by setting all fields to None
for name in time_frames.keys():
item[name] = None
def filter_data_quarterly(data):
# Generate a range of quarter-end dates from the start to the end date
start_date = data[0]['date']