From 7d59885c36388792e6de6379d86832decbaceb1e Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Sun, 24 Nov 2024 17:40:24 +0100 Subject: [PATCH] bugfixing --- app/cron_list.py | 31 +++++++++++++++---------------- app/restart_json.py | 7 ++++--- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/app/cron_list.py b/app/cron_list.py index eebf05d..c123bcb 100644 --- a/app/cron_list.py +++ b/app/cron_list.py @@ -174,9 +174,9 @@ async def get_etf_provider(etf_con): if sorted_res: with open(f"json/etf/provider/{provider}.json", 'wb') as file: file.write(orjson.dumps(sorted_res)) - except: + except Exception as e: + print(e) pass - cursor.close() @@ -205,8 +205,8 @@ async def get_magnificent_seven(): 'changesPercentage': changesPercentage, 'marketCap': marketCap, \ 'revenue': revenue}) - except: - pass + except Exception as e: + print(e) if res_list: res_list = sorted(res_list, key=lambda x: x['marketCap'], reverse=True) @@ -241,8 +241,8 @@ async def get_faang(): 'changesPercentage': changesPercentage, 'marketCap': marketCap, \ 'revenue': revenue}) - except: - pass + except Exception as e: + print(e) if res_list: res_list = sorted(res_list, key=lambda x: x['marketCap'], reverse=True) @@ -286,8 +286,8 @@ async def get_penny_stocks(): 'volume': volume }) - except: - pass + except Exception as e: + print(e) if res_list: # Sort by market cap in descending order @@ -336,8 +336,8 @@ async def get_oversold_stocks(): 'rsi': rsi }) - except: - pass + except Exception as e: + print(e) if res_list: # Sort by market cap in descending order @@ -386,8 +386,8 @@ async def get_overbought_stocks(): 'rsi': rsi }) - except: - pass + except Exception as e: + print(e) if res_list: # Sort by market cap in descending order @@ -417,8 +417,8 @@ async def get_top_dividend_stocks(): analyst_counter = stock_screener_data_dict[symbol].get('analystCounter',0) dividend_yield = stock_screener_data_dict[symbol].get('dividendYield',0) payout_ratio = stock_screener_data_dict[symbol].get('payoutRatio',100) - - if analyst_rating in ['Buy','Strong Buy'] and analyst_counter >= 10 and dividend_yield > 2 and payout_ratio < 60: + country = stock_screener_data_dict[symbol].get('country',None) + if country == 'United States' and analyst_rating in ['Buy','Strong Buy'] and analyst_counter >= 10 and dividend_yield >=2 and payout_ratio < 60: quote_data = await get_quote_data(symbol) # Assign price and volume, and check if they meet the penny stock criteria @@ -437,8 +437,7 @@ async def get_top_dividend_stocks(): 'marketCap': marketCap, 'dividendYield': dividend_yield }) - except Exception as e: - print(e) + except: pass if res_list: diff --git a/app/restart_json.py b/app/restart_json.py index a2d5c17..bee1171 100755 --- a/app/restart_json.py +++ b/app/restart_json.py @@ -759,14 +759,15 @@ async def get_stock_screener(con): with open(f"json/dividends/companies/{symbol}.json", 'r') as file: res = orjson.loads(file.read()) item['annualDividend'] = round(res['annualDividend'],2) + item['dividendYield'] = round(res['dividendYield'],2) + item['payoutRatio'] = round(res['payoutRatio'],2) item['dividendGrowth'] = round(res['dividendGrowth'],2) except: item['annualDividend'] = None + item['dividendYield'] = None + item['payoutRatio'] = None item['dividendGrowth'] = None - #data is from financialdata - item['dividendYield'] = round(item['dividendYield'] * 100, 2) if item['dividendYield'] is not None else item['dividendYield'] - item['payoutRatio'] = round(item['payoutRatio'] * 100, 2) if item['payoutRatio'] is not None else item['payoutRatio'] try: