Update rsi_agent.py
Browse files- rsi_agent.py +18 -2
rsi_agent.py
CHANGED
|
@@ -1,7 +1,23 @@
|
|
| 1 |
from ta.momentum import RSIIndicator
|
| 2 |
|
| 3 |
class RSIAlertAgent:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
def run(self, df):
|
| 5 |
rsi = RSIIndicator(close=df['Close'], window=14).rsi().iloc[-1]
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from ta.momentum import RSIIndicator
|
| 2 |
|
| 3 |
class RSIAlertAgent:
|
| 4 |
+
"""
|
| 5 |
+
Detects RSI-based signals for overbought/oversold conditions.
|
| 6 |
+
Returns structured signal info for use in dashboards and decision logic.
|
| 7 |
+
"""
|
| 8 |
+
|
| 9 |
def run(self, df):
|
| 10 |
rsi = RSIIndicator(close=df['Close'], window=14).rsi().iloc[-1]
|
| 11 |
+
|
| 12 |
+
if rsi > 70:
|
| 13 |
+
signal = "Overbought"
|
| 14 |
+
elif rsi < 30:
|
| 15 |
+
signal = "Oversold"
|
| 16 |
+
else:
|
| 17 |
+
signal = "Neutral"
|
| 18 |
+
|
| 19 |
+
return {
|
| 20 |
+
"signal": signal,
|
| 21 |
+
"rsi": round(rsi, 2),
|
| 22 |
+
"status": "β
" if signal != "Neutral" else "β οΈ"
|
| 23 |
+
}
|