Update fundamental_agent.py
Browse files- fundamental_agent.py +11 -4
fundamental_agent.py
CHANGED
|
@@ -6,6 +6,8 @@ def analyze_fundamentals(tickers):
|
|
| 6 |
|
| 7 |
for ticker in tickers:
|
| 8 |
|
|
|
|
|
|
|
| 9 |
try:
|
| 10 |
|
| 11 |
info = yf.Ticker(ticker).info
|
|
@@ -13,8 +15,8 @@ def analyze_fundamentals(tickers):
|
|
| 13 |
pe = info.get("trailingPE")
|
| 14 |
roe = info.get("returnOnEquity")
|
| 15 |
debt = info.get("debtToEquity")
|
| 16 |
-
|
| 17 |
-
|
| 18 |
|
| 19 |
if pe and pe < 40:
|
| 20 |
score += 1
|
|
@@ -25,10 +27,15 @@ def analyze_fundamentals(tickers):
|
|
| 25 |
if debt and debt < 1:
|
| 26 |
score += 1
|
| 27 |
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
except:
|
|
|
|
| 31 |
|
| 32 |
-
|
| 33 |
|
| 34 |
return results
|
|
|
|
| 6 |
|
| 7 |
for ticker in tickers:
|
| 8 |
|
| 9 |
+
score = 0
|
| 10 |
+
|
| 11 |
try:
|
| 12 |
|
| 13 |
info = yf.Ticker(ticker).info
|
|
|
|
| 15 |
pe = info.get("trailingPE")
|
| 16 |
roe = info.get("returnOnEquity")
|
| 17 |
debt = info.get("debtToEquity")
|
| 18 |
+
margin = info.get("profitMargins")
|
| 19 |
+
growth = info.get("earningsGrowth")
|
| 20 |
|
| 21 |
if pe and pe < 40:
|
| 22 |
score += 1
|
|
|
|
| 27 |
if debt and debt < 1:
|
| 28 |
score += 1
|
| 29 |
|
| 30 |
+
if margin and margin > 0.1:
|
| 31 |
+
score += 1
|
| 32 |
+
|
| 33 |
+
if growth and growth > 0.1:
|
| 34 |
+
score += 1
|
| 35 |
|
| 36 |
except:
|
| 37 |
+
pass
|
| 38 |
|
| 39 |
+
results[ticker] = score
|
| 40 |
|
| 41 |
return results
|