diff --git a/app_streamlit.py b/app_streamlit.py index 0fb8985..88b1480 100644 --- a/app_streamlit.py +++ b/app_streamlit.py @@ -75,14 +75,14 @@ def check_and_alert(df, symbol, interval): global _long_entry, _short_entry now = time.time() recent = df.tail(3) - for sig, key, msg 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}"), - ("short_signal", "short", f"🔽 숏 진입 신호\n{symbol} {interval}"), - ("vol_long_signal", "vol_long", f"🔼 볼륨급등 롱 신호\n{symbol} {interval}"), - ("vol_short_signal", "vol_short", f"🔽 볼륨급등 숏 신호\n{symbol} {interval}"), - ("short_caution_signal","short_caution",f"⚠️ 숏 진입 주의 신호\n{symbol} {interval}"), + for sig, key, label in [ + ("strong_long_signal", "strong_long", "🟢 강한 롱 진입 신호"), + ("strong_short_signal", "strong_short", "🔴 강한 숏 진입 신호"), + ("long_signal", "long", "🔼 롱 진입 신호"), + ("short_signal", "short", "🔽 숏 진입 신호"), + ("vol_long_signal", "vol_long", "🔼 볼륨급등 롱 신호"), + ("vol_short_signal", "vol_short", "🔽 볼륨급등 숏 신호"), + ("short_caution_signal","short_caution","⚠️ 숏 진입 주의 신호"), ]: if sig not in recent.columns: continue @@ -94,17 +94,24 @@ def check_and_alert(df, symbol, interval): continue if now - _last_alert[key] <= ALERT_COOLDOWN: continue + + if sig in LONG_SIGNALS: + entry_price = float(triggered.iloc[-1]["low"]) * 0.9998 + stop_price = entry_price * (1 - STOP_LOSS_PCT) + msg = f"{label}\n{symbol} {interval}\n진입가: {entry_price:.2f}\n손절가: {stop_price:.2f}" + _long_entry = {"price": entry_price, "stop": stop_price, "open_time": candle_time} + elif sig in SHORT_SIGNALS: + entry_price = float(triggered.iloc[-1]["high"]) * 1.0002 + stop_price = entry_price * (1 + STOP_LOSS_PCT) + msg = f"{label}\n{symbol} {interval}\n진입가: {entry_price:.2f}\n손절가: {stop_price:.2f}" + _short_entry = {"price": entry_price, "stop": stop_price, "open_time": candle_time} + else: + msg = f"{label}\n{symbol} {interval}" + send_telegram(msg) _last_alert[key] = now _last_fired_candle[key] = candle_time - if sig in LONG_SIGNALS: - entry_price = float(triggered.iloc[-1]["close"]) - _long_entry = {"price": entry_price, "stop": entry_price * (1 - STOP_LOSS_PCT), "open_time": candle_time} - elif sig in SHORT_SIGNALS: - entry_price = float(triggered.iloc[-1]["close"]) - _short_entry = {"price": entry_price, "stop": entry_price * (1 + STOP_LOSS_PCT), "open_time": candle_time} - current_price = float(df.iloc[-1]["close"]) if _long_entry is not None and current_price <= _long_entry["stop"]: send_telegram(