feat: granular Telegram notification filters via .env #161

Closed
opened 2026-02-20 02:23:48 +09:00 by agentson · 0 comments
Collaborator

Problem

텔레그램 메시지가 너무 많이 발송됨. 특히 notify_scenario_matched가 60초마다 종목별로 전송되어 가장 빈번함.

Solution

알림 유형별로 .env에서 on/off 가능하도록 세분화된 필터 추가:

  • TELEGRAM_NOTIFY_TRADES — BUY/SELL 체결 알림
  • TELEGRAM_NOTIFY_MARKET_OPEN_CLOSE — 장 시작/종료 알림
  • TELEGRAM_NOTIFY_FAT_FINGER — 팻핑거 보호 알림
  • TELEGRAM_NOTIFY_SYSTEM_EVENTS — 시스템 시작/종료 알림
  • TELEGRAM_NOTIFY_PLAYBOOK — 플레이북 생성/실패 알림
  • TELEGRAM_NOTIFY_SCENARIO_MATCH — 시나리오 매칭 알림 (가장 빈번)
  • TELEGRAM_NOTIFY_ERRORS — 에러 알림

참고: circuit_breaker 알림은 안전상 항상 전송 (비활성화 불가)

Files Changed

  • src/config.py — 7개 설정 추가
  • src/notifications/telegram_client.py — NotificationFilter dataclass + 각 메서드에 가드 추가
  • src/main.py — TelegramClient 생성 시 NotificationFilter 전달
  • tests/test_telegram.py — 필터 동작 테스트 추가
## Problem 텔레그램 메시지가 너무 많이 발송됨. 특히 `notify_scenario_matched`가 60초마다 종목별로 전송되어 가장 빈번함. ## Solution 알림 유형별로 .env에서 on/off 가능하도록 세분화된 필터 추가: - `TELEGRAM_NOTIFY_TRADES` — BUY/SELL 체결 알림 - `TELEGRAM_NOTIFY_MARKET_OPEN_CLOSE` — 장 시작/종료 알림 - `TELEGRAM_NOTIFY_FAT_FINGER` — 팻핑거 보호 알림 - `TELEGRAM_NOTIFY_SYSTEM_EVENTS` — 시스템 시작/종료 알림 - `TELEGRAM_NOTIFY_PLAYBOOK` — 플레이북 생성/실패 알림 - `TELEGRAM_NOTIFY_SCENARIO_MATCH` — 시나리오 매칭 알림 (가장 빈번) - `TELEGRAM_NOTIFY_ERRORS` — 에러 알림 참고: circuit_breaker 알림은 안전상 항상 전송 (비활성화 불가) ## Files Changed - `src/config.py` — 7개 설정 추가 - `src/notifications/telegram_client.py` — NotificationFilter dataclass + 각 메서드에 가드 추가 - `src/main.py` — TelegramClient 생성 시 NotificationFilter 전달 - `tests/test_telegram.py` — 필터 동작 테스트 추가
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: jihoson/The-Ouroboros#161