"""Alert manager -- unified notification dispatch. Coordinates sending notifications through multiple channels (currently Telegram, extensible to Discord, email, etc.). """ from __future__ import annotations from typing import List from loguru import logger from notification.telegram_bot import TelegramNotifier class AlertManager: """Dispatch alerts to all configured notification channels.""" def __init__(self, notifiers: List | None = None): if notifiers is None: self._notifiers = [TelegramNotifier()] else: self._notifiers = notifiers async def notify_signal(self, signal_data: dict) -> None: """Broadcast a trade signal to all channels.""" for n in self._notifiers: try: await n.send_signal(**signal_data) except Exception as e: logger.error("Alert dispatch failed: {}", e) async def notify_fill(self, fill_data: dict) -> None: for n in self._notifiers: try: await n.send_fill(**fill_data) except Exception as e: logger.error("Alert dispatch failed: {}", e) async def notify_close(self, close_data: dict) -> None: for n in self._notifiers: try: await n.send_close(**close_data) except Exception as e: logger.error("Alert dispatch failed: {}", e) async def notify_error(self, error: str) -> None: for n in self._notifiers: try: await n.send_error(error) except Exception as e: logger.error("Alert dispatch failed: {}", e) async def notify_emergency(self, msg: str) -> None: for n in self._notifiers: try: await n.send_emergency(msg) except Exception as e: logger.error("Alert dispatch failed: {}", e)