diff --git a/app_streamlit.py b/app_streamlit.py index d46faae..afb4a62 100644 --- a/app_streamlit.py +++ b/app_streamlit.py @@ -736,17 +736,26 @@ def send_daily_report(symbol="BTCUSDT"): lines.append(f"합계: {passed_all}T {failed_all}F (승률 {rate:.2f}%)") send_telegram("\n".join(lines)) +_last_report_date = None + def _daily_report_loop(): + global _last_report_date while True: - now = datetime.now(timezone.utc) + KST - next_mid = (now + timedelta(days=1)).replace(hour=0, minute=0, second=0, microsecond=0) - time.sleep(max(60, (next_mid - now).total_seconds())) try: - with _alert_lock: - symbol = _alert_symbol - send_daily_report(symbol) + now_kst = (datetime.now(timezone.utc) + KST).replace(tzinfo=None) + today_str = now_kst.strftime("%Y-%m-%d") + if _last_report_date is None: + _last_report_date = today_str + print(f"[일일리포트] 스레드 기동 — 다음 자정({today_str} 24:00 KST) 까지 대기") + elif _last_report_date != today_str: + print(f"[일일리포트] 자정 통과 감지 → 발송 ({today_str})") + with _alert_lock: + symbol = _alert_symbol + send_daily_report(symbol) + _last_report_date = today_str except Exception as e: print(f"[일일리포트 스레드 오류] {e}") + time.sleep(60) # ────────────────────────────────────────────── # 메인 UI