From 42b7118c8ee257052a5a4f260c0b7739c80ecea1 Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Mon, 14 Apr 2025 23:07:59 +0200 Subject: [PATCH] bugfixing --- app/cron_discord_bot.py | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/app/cron_discord_bot.py b/app/cron_discord_bot.py index 246aeb5..750ebf6 100644 --- a/app/cron_discord_bot.py +++ b/app/cron_discord_bot.py @@ -314,12 +314,26 @@ def recent_earnings(): seen_list = [] with open(f"json/dashboard/data.json", 'rb') as file: - res_list = orjson.loads(file.read())['recentEarnings'] + data = orjson.loads(file.read())['recentEarnings'] - for item in res_list: - - unique_str = f"{item['date']}-{item['symbol']}-{item['revenue']}-{item['eps']}" - item['id'] = hashlib.md5(unique_str.encode()).hexdigest() + res_list = [] + for item in data: + try: + with open(f"json/quote/{item['symbol']}.json","r") as file: + quote_data = orjson.loads(file.read()) + + item['price'] = round(quote_data.get('price',0),2) + item['changesPercentage'] = round(quote_data.get('changesPercentage',0),2) + item['marketCap'] = quote_data.get('marketCap',0) + item['eps'] = round(quote_data.get('eps',0),2) + + unique_str = f"{item['date']}-{item['symbol']}" + item['id'] = hashlib.md5(unique_str.encode()).hexdigest() + res_list.append(item) + except: + pass + + print(res_list) if res_list: @@ -331,7 +345,7 @@ def recent_earnings(): for item in res_list: try: - if item != None and item['id'] not in seen_ids and item['marketCap'] > 100E9: + if item != None and item['id'] not in seen_ids and item['marketCap']: symbol = item['symbol'] price = item['price'] changes_percentage = round(item['changesPercentage'],2) @@ -376,7 +390,7 @@ def recent_earnings(): "embeds": [embed] } - response = requests.post(RECENT_EARNINGS_WEBHOOK_URL, json=payload) + #response = requests.post(RECENT_EARNINGS_WEBHOOK_URL, json=payload) if response.status_code in (200, 204): seen_list.append({'date': item['date'], 'id': item['id'], 'symbol': symbol}) @@ -395,8 +409,8 @@ def recent_earnings(): try: with open("json/discord/recent_earnings.json","wb") as file: file.write(orjson.dumps(seen_list)) - except: - pass + except Exception as e: + print(e) def executive_order_message(): @@ -558,8 +572,8 @@ def analyst_report(): if __name__ == "__main__": - options_flow() - dark_pool_flow() + #options_flow() + #dark_pool_flow() recent_earnings() - executive_order_message() - analyst_report() + #executive_order_message() + #analyst_report()