diff --git a/app_streamlit.py b/app_streamlit.py index a46ea69..692f0ae 100644 --- a/app_streamlit.py +++ b/app_streamlit.py @@ -95,22 +95,26 @@ def check_and_alert(df, symbol, interval): return forming_ct = df.iloc[-1]["open_time"] - # Phase 1 — pending_groups 검증. + # Phase 1 — pending_groups 검증. forming candle 이라도 매 polling 마다 신호 + # 상태 확인. 사라지면 즉시 [취소 알림] (캔들 마감까지 기다리지 않음). new_pending = [] for p in alert_state.pending_groups: if p["interval"] != interval: new_pending.append(p) continue ct = p["candle_time"] - if ct == forming_ct: - new_pending.append(p) - continue row_match = df[df["open_time"] == ct] if row_match.empty: - continue + continue # 캔들이 df 윈도우 밖 — 검증 포기, drop row = row_match.iloc[0] any_still_true = any(bool(row.get(s, False)) for s in p["sig_cols"]) - if not any_still_true: + if any_still_true: + if ct == forming_ct: + # forming 중 + 신호 살아있음 → 계속 감시 + new_pending.append(p) + # closed + 신호 살아있음 → 확정, pending 에서 제거 + else: + # 신호 사라짐 (forming/closed 무관) → 즉시 취소 알림 send_telegram(f"[취소 알림]\n{p['msg']}") le = alert_state.long_entry.get(interval) se = alert_state.short_entry.get(interval)