From bf99b2949b3f12adc8fce162f1b5670bb63dc455 Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Fri, 21 Jun 2024 08:07:42 +0200 Subject: [PATCH] bugfixing --- app/cron_retail_volume.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/cron_retail_volume.py b/app/cron_retail_volume.py index 2c0dc8a..da8cee2 100644 --- a/app/cron_retail_volume.py +++ b/app/cron_retail_volume.py @@ -105,8 +105,9 @@ async def run(): try: filtered_data = [item for item in transformed_data if symbol == item['symbol']] res = filter_past_six_months(filtered_data) - query_template = query_stocks_template if symbol in stocks_symbols else query_etf_template + query_template = query_stock_template if symbol in stocks_symbols else query_etf_template connection = con if symbol in stocks_symbols else etf_con + #Compute strength of retail investors last_trade = res[-1]['traded'] last_sentiment = int(res[-1]['sentiment']) @@ -119,19 +120,17 @@ async def run(): name = data['name'].iloc[0] company_data = {'lastDate': last_date, 'lastTrade': last_trade, 'lastSentiment': last_sentiment, 'retailStrength': retailer_strength, 'history': res} - await save_json(symbol, company_data) #Add stocks for most retail volume if symbol in stocks_symbols: most_retail_volume.append({'symbol': res[-1]['symbol'], 'name': name, 'traded': res[-1]['traded'], 'sentiment': res[-1]['sentiment'], 'retailStrength': retailer_strength}) - except: - pass + except Exception as e: + print(e) most_retail_volume = [item for item in most_retail_volume if item['retailStrength'] <= 100] most_retail_volume = sorted(most_retail_volume, key=lambda x: x['traded'], reverse=True)[:100] # top 100 retail volume stocks - with open(f"json/retail-volume/data.json", 'w') as file: ujson.dump(most_retail_volume, file)