Spaces:
Sleeping

Signal_bot / regime_engine.py
404chain's picture
Create regime_engine.py
722b839 verified
Raw History Blame Contribute Delete
2.23 kB
# =========================================================
# MARKET REGIME ENGINE
# =========================================================
def detect_market_regime(ta):
rsi = ta["rsi"]
macd = ta["macd"]
trend = ta["trend"]
confidence = ta["confidence"]
regime = "NEUTRAL"
description = ""
# =====================================================
# OVERBOUGHT
# =====================================================
if rsi >= 70:
regime = "OVERBOUGHT"
description = (
"Market terlalu panas. "
"Potensi pullback meningkat."
)
# =====================================================
# OVERSOLD
# =====================================================
elif rsi <= 30:
regime = "OVERSOLD"
description = (
"Market oversold. "
"Potensi rebound meningkat."
)
# =====================================================
# STRONG BULLISH
# =====================================================
elif trend == "BULLISH" and confidence >= 75:
regime = "STRONG BULLISH"
description = (
"Momentum bullish kuat. "
"Trend continuation dominan."
)
# =====================================================
# STRONG BEARISH
# =====================================================
elif trend == "BEARISH" and confidence >= 75:
regime = "STRONG BEARISH"
description = (
"Tekanan bearish kuat. "
"Risk high volatility."
)
# =====================================================
# SIDEWAYS
# =====================================================
elif confidence < 60:
regime = "SIDEWAYS"
description = (
"Market sedang ranging "
"dan tidak punya arah kuat."
)
# =====================================================
# DEFAULT
# =====================================================
else:
regime = "NEUTRAL"
description = (
"Momentum market moderat."
)
return {
"regime": regime,
"description": description
}