AI Trading Bot Notification System Telegram Email Discord

We design and deploy artificial intelligence systems: from prototype to production-ready solutions. Our team combines expertise in machine learning, data engineering and MLOps to make AI work not in the lab, but in real business.
Showing 1 of 1 servicesAll 1566 services
AI Trading Bot Notification System Telegram Email Discord
Simple
~1 business day
FAQ
AI Development Areas
AI Solution Development Stages
Latest works
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1161
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1041
  • image_logo-advance_0.png
    B2B Advance company logo design
    561
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    823
  • image_logo-aider_0.jpg
    AIDER company logo development
    762
  • image_crm_chasseurs_493_0.webp
    CRM development for Chasseurs
    848

Разработка системы уведомлений AI-трейдинг-бота Telegram Email Discord

Система уведомлений — критичный элемент трейдинг-бота. Нужно знать о каждой сделке, проблеме с соединением, превышении лимитов риска — немедленно, на любом устройстве.

Типы событий для уведомлений

Торговые события (немедленно)

  • Открытие/закрытие позиции
  • Исполнение/отмена ордера
  • Достижение stop-loss или take-profit
  • Частичное исполнение

Риск-события (немедленно)

  • Drawdown > threshold (5%, 10%, 20%)
  • Daily loss limit приближается
  • Аномальный P&L (необычно большая прибыль/убыток)

Технические события (немедленно)

  • Ошибка соединения с биржей
  • Bot exception/crash
  • Ошибка размещения ордера

Отчёты (по расписанию)

  • Daily summary
  • Weekly performance report
  • Monthly statistics

Multi-channel архитектура

from abc import ABC, abstractmethod
from typing import List
import asyncio

class NotificationChannel(ABC):
    @abstractmethod
    async def send(self, message: str, priority: str = 'normal') -> bool:
        pass

class TelegramChannel(NotificationChannel):
    def __init__(self, token: str, chat_ids: List[int]):
        self.bot = Bot(token=token)
        self.chat_ids = chat_ids

    async def send(self, message: str, priority: str = 'normal') -> bool:
        for chat_id in self.chat_ids:
            await self.bot.send_message(chat_id, message, parse_mode='Markdown')
        return True

class EmailChannel(NotificationChannel):
    def __init__(self, smtp_config: dict, recipients: List[str]):
        self.smtp_config = smtp_config
        self.recipients = recipients

    async def send(self, message: str, priority: str = 'normal') -> bool:
        # Async SMTP через aiosmtplib
        import aiosmtplib
        msg = MIMEText(message)
        msg['Subject'] = f"[TradingBot] {priority.upper()} Alert"
        async with aiosmtplib.SMTP(**self.smtp_config) as smtp:
            await smtp.send_message(msg, self.smtp_config['username'], self.recipients)
        return True

class DiscordChannel(NotificationChannel):
    def __init__(self, webhook_url: str):
        self.webhook_url = webhook_url

    async def send(self, message: str, priority: str = 'normal') -> bool:
        import aiohttp
        color = 0xFF0000 if priority == 'critical' else 0x00FF00
        payload = {"embeds": [{"description": message, "color": color}]}
        async with aiohttp.ClientSession() as session:
            await session.post(self.webhook_url, json=payload)
        return True

class NotificationRouter:
    def __init__(self):
        self.channels = {
            'critical': [TelegramChannel(...), EmailChannel(...)],
            'high': [TelegramChannel(...)],
            'normal': [TelegramChannel(...)],
            'report': [EmailChannel(...), DiscordChannel(...)]
        }

    async def notify(self, message: str, priority: str = 'normal'):
        channels = self.channels.get(priority, self.channels['normal'])
        await asyncio.gather(*[ch.send(message, priority) for ch in channels])

Форматирование сообщений

def format_trade_message(trade):
    emoji = "🟢" if trade['pnl'] > 0 else "🔴"
    return f"""
{emoji} *Trade Closed*
Pair: `{trade['symbol']}`
Side: {trade['side'].upper()}
Entry: `${trade['entry_price']:.2f}` → Exit: `${trade['exit_price']:.2f}`
P&L: `{trade['pnl']:+.2f}%` (`${trade['pnl_usd']:+.2f}`)
Duration: {trade['duration']}
Reason: {trade['close_reason']}
"""

def format_daily_report(stats):
    return f"""
📊 *Daily Report — {stats['date']}*
Trades: {stats['total_trades']} ({stats['wins']}W/{stats['losses']}L)
Win Rate: `{stats['win_rate']:.1f}%`
P&L: `{stats['daily_pnl']:+.2f}%` (`${stats['daily_pnl_usd']:+.2f}`)
Max Drawdown: `{stats['max_drawdown']:.2f}%`
Sharpe (30d): `{stats['sharpe_30d']:.2f}`
"""

Rate Limiting уведомлений

При высокой частоте торговли — spam защита:

  • Aggregation: "5 trades in last minute" вместо 5 отдельных сообщений
  • Cooldown: повторный алерт того же типа не чаще раз в N минут
  • Priority override: critical-алерты всегда немедленно

Срок разработки: 1–2 недели для multi-channel системы.