auto: 일일 백업 2026-09-11 02:00

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
hyowons
2026-09-11 02:00:03 +09:00
parent 92d0d96368
commit b4f510d1ad
188 changed files with 4782 additions and 3353 deletions
@@ -79,11 +79,27 @@ from orders.handler import send_telegram # noqa: E402
# 정정 실패 알림 쿨다운 — NXT 시간대에 KRX/SOR 원주문 정정이 거부되면 매 사이클 반복된다.
FAIL_NOTICE_COOLDOWN_SEC = 1800
# 사이클마다 mtime 만 갱신하는 생존 신호. 이 감시가 죽으면 예약 트레일링(ARM)이
# 아예 발동하지 않는데, 예약 0건이면 로그를 한 줄도 남기지 않아 바깥에서 죽었는지
# 구분할 방법이 없었다(2026-08-28 이후 13일간 로그 무갱신이 정상인지 장애인지 불명).
# 로그로 찍으면 분당 1줄 × 720회/일이 쌓여 실제 이벤트를 덮으므로 파일 mtime 만 쓴다.
# scripts/health_check.py 가 이 파일을 읽는다.
HEARTBEAT_FILE = WORKSPACE / 'state' / 'trailing_monitor_heartbeat'
def _log(msg: str) -> None:
print(f'[{datetime.now(KST).strftime("%Y-%m-%d %H:%M:%S")}] {msg}', flush=True)
def _heartbeat() -> None:
"""감시가 이번 사이클을 돌았다는 신호. 실패해도 감시를 막지 않는다."""
try:
HEARTBEAT_FILE.write_text(
datetime.now(KST).isoformat(timespec='seconds'), encoding='utf-8')
except Exception:
pass
def session_now() -> tuple[bool, str]:
"""(감시할 세션인가, 세션명). 주말·휴장일·거래시간 외는 False.
@@ -435,6 +451,7 @@ def _worth_running(force: bool) -> bool:
def check(force: bool = False, dry_run: bool = False) -> int:
_heartbeat()
reservations = trailing.list_active()
arms = trailing.list_arms()
if not reservations and not arms: