| import yfinance as yf | |
| def analyze_fundamentals(tickers): | |
| results = {} | |
| for ticker in tickers: | |
| score = 0 | |
| try: | |
| info = yf.Ticker(ticker).info | |
| pe = info.get("trailingPE") | |
| roe = info.get("returnOnEquity") | |
| debt = info.get("debtToEquity") | |
| margin = info.get("profitMargins") | |
| growth = info.get("earningsGrowth") | |
| if pe and pe < 40: | |
| score += 1 | |
| if roe and roe > 0.15: | |
| score += 1 | |
| if debt and debt < 1: | |
| score += 1 | |
| if margin and margin > 0.1: | |
| score += 1 | |
| if growth and growth > 0.1: | |
| score += 1 | |
| except: | |
| pass | |
| results[ticker] = score | |
| return results |