bugfixing

This commit is contained in:
MuslemRahimi 2024-11-24 17:12:52 +01:00
parent 096accc9ab
commit 0ed18d3c10
2 changed files with 19 additions and 18 deletions

View File

@ -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 Exception as e:
print(e)
except:
pass
cursor.close()
@ -205,8 +205,8 @@ async def get_magnificent_seven():
'changesPercentage': changesPercentage, 'marketCap': marketCap, \
'revenue': revenue})
except Exception as e:
print(e)
except:
pass
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 Exception as e:
print(e)
except:
pass
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 Exception as e:
print(e)
except:
pass
if res_list:
# Sort by market cap in descending order
@ -336,8 +336,8 @@ async def get_oversold_stocks():
'rsi': rsi
})
except Exception as e:
print(e)
except:
pass
if res_list:
# Sort by market cap in descending order
@ -386,8 +386,8 @@ async def get_overbought_stocks():
'rsi': rsi
})
except Exception as e:
print(e)
except:
pass
if res_list:
# Sort by market cap in descending order
@ -417,7 +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:
if 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
@ -436,7 +437,8 @@ async def get_top_dividend_stocks():
'marketCap': marketCap,
'dividendYield': dividend_yield
})
except:
except Exception as e:
print(e)
pass
if res_list:

View File

@ -759,15 +759,14 @@ 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: