diff --git a/app_streamlit.py b/app_streamlit.py index 5b39c6a..f15b7c1 100644 --- a/app_streamlit.py +++ b/app_streamlit.py @@ -53,6 +53,7 @@ BASE = "https://fapi.binance.com" KST = timedelta(hours=9) _last_alert = {"strong_long": 0, "strong_short": 0, "long": 0, "short": 0, "vol_long": 0, "vol_short": 0, "short_caution": 0} +_last_fired_candle = {"strong_long": None, "strong_short": None, "long": None, "short": None, "vol_long": None, "vol_short": None, "short_caution": None} # ────────────────────────────────────────────── # 텔레그램 @@ -76,9 +77,19 @@ def check_and_alert(df, symbol, interval): ("vol_short_signal", "vol_short", f"🔽 볼륨급등 숏 신호\n{symbol} {interval}"), ("short_caution_signal","short_caution",f"⚠️ 숏 진입 주의 신호\n{symbol} {interval}"), ]: - if sig in recent.columns and recent[sig].fillna(False).any() and now - _last_alert[key] > ALERT_COOLDOWN: - send_telegram(msg) - _last_alert[key] = now + if sig not in recent.columns: + continue + triggered = recent[recent[sig].fillna(False)] + if triggered.empty: + continue + candle_time = triggered.iloc[-1]["open_time"] + if candle_time == _last_fired_candle.get(key): + continue + if now - _last_alert[key] <= ALERT_COOLDOWN: + continue + send_telegram(msg) + _last_alert[key] = now + _last_fired_candle[key] = candle_time # ────────────────────────────────────────────── # 데이터 수집