From ffb9a36ff14bded21720bd03f92e6eb051d1eeaa Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Mon, 28 Oct 2024 19:00:06 +0100 Subject: [PATCH] update market movers --- app/cron_market_movers.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/cron_market_movers.py b/app/cron_market_movers.py index 7d644a5..f93b4db 100755 --- a/app/cron_market_movers.py +++ b/app/cron_market_movers.py @@ -140,7 +140,8 @@ async def get_gainer_loser_active_stocks(): volume = pd.read_sql_query(query, con) entry['marketCap'] = int(fundamental_data['marketCap'].iloc[0]) entry['volume'] = int(volume['volume'].iloc[0]) - if entry['marketCap'] >= market_cap_threshold and entry['volume'] >= volume_threshold: + entry['changesPercentage'] = round(entry['changesPercentage'],2) + if entry['marketCap'] >= market_cap_threshold and entry['volume'] >= volume_threshold and abs(entry['changesPercentage']) < 500: filtered_gainer_json.append(entry) except: entry['marketCap'] = None @@ -156,7 +157,8 @@ async def get_gainer_loser_active_stocks(): volume = pd.read_sql_query(query, con) entry['marketCap'] = int(fundamental_data['marketCap'].iloc[0]) entry['volume'] = int(volume['volume'].iloc[0]) - if entry['marketCap'] >= market_cap_threshold and entry['volume'] >= volume_threshold: + entry['changesPercentage'] = round(entry['changesPercentage'],2) + if entry['marketCap'] >= market_cap_threshold and entry['volume'] >= volume_threshold and abs(entry['changesPercentage']) < 500: filtered_loser_json.append(entry) except: entry['marketCap'] = None @@ -173,7 +175,9 @@ async def get_gainer_loser_active_stocks(): volume = pd.read_sql_query(query, con) entry['marketCap'] = int(fundamental_data['marketCap'].iloc[0]) entry['volume'] = int(volume['volume'].iloc[0]) - filtered_active_json.append(entry) + entry['changesPercentage'] = round(entry['changesPercentage'],2) + if abs(entry['changesPercentage']) < 500: + filtered_active_json.append(entry) except: entry['marketCap'] = None entry['volume'] = None @@ -194,7 +198,7 @@ async def get_gainer_loser_active_stocks(): SELECT gainer,loser,most_active FROM - market_movers + market_movers """ past_gainer = pd.read_sql_query(query_market_movers, con)