diff --git a/app_streamlit.py b/app_streamlit.py index e65104d..7286442 100644 --- a/app_streamlit.py +++ b/app_streamlit.py @@ -66,8 +66,8 @@ def send_telegram(message: str): def check_and_alert(df, symbol, interval): now = time.time() - last = df.iloc[-1] - for sig, key, msg in [ + recent = df.iloc[-3:] # 마지막 3개 캔들 체크 + for sig, key, msg_base in [ ("strong_long_signal", "strong_long", f"🟢 강한 롱 진입 신호\n{symbol} {interval}"), ("strong_short_signal", "strong_short", f"🔴 강한 숏 진입 신호\n{symbol} {interval}"), ("long_signal", "long", f"🔼 롱 진입 신호\n{symbol} {interval}"), @@ -76,7 +76,12 @@ 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 last.get(sig, False) and now - _last_alert[key] > ALERT_COOLDOWN: + if sig in recent.columns and recent[sig].any() and now - _last_alert[key] > ALERT_COOLDOWN: + sig_row = recent[recent[sig] == True].iloc[-1] + sig_time = sig_row["open_time"].strftime("%H:%M") if "open_time" in sig_row else "" + price = f"{sig_row['close']:,.1f}" if "close" in sig_row else "" + msg = f"{msg_base}\n시간: {sig_time} 가격: {price}" + print(f"[알림발송] {msg_base.split(chr(10))[0]} | {sig_time} | {price}") send_telegram(msg) _last_alert[key] = now @@ -581,8 +586,6 @@ def main(): with col4: refresh_sec = st.number_input("갱신(초)", min_value=10, max_value=300, value=30) with col5: - now_kst = datetime.now(timezone.utc) + KST - st.markdown(f"
🕐 마지막 갱신: {now_kst.strftime('%Y-%m-%d %H:%M:%S')} KST
", unsafe_allow_html=True) col5a, col5b, col5c, col5d = st.columns(4) with col5a: refresh_btn = st.button("🔄 새로고침") @@ -625,7 +628,7 @@ def main(): "modeBarButtonsToRemove": ["lasso2d", "select2d"], }) - + st.caption(f"마지막 갱신: {datetime.now().strftime('%H:%M:%S')}") except Exception as e: st.error(f"데이터 로드 오류: {e}")