알림 3캔들 체크 + 시간/가격 추가

This commit is contained in:
ILSEON-RYU
2026-04-29 18:00:20 +09:00
parent 38db7cac09
commit dfe3a2c19a
+9 -6
View File
@@ -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"<div style='text-align:right; font-size:12px; color:#888; margin-bottom:2px;'>🕐 마지막 갱신: {now_kst.strftime('%Y-%m-%d %H:%M:%S')} KST</div>", 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}")