Skip to content

Telegram 알림

Telegram Bot을 통해 트레이딩 이벤트를 실시간으로 받을 수 있습니다.

Bot 생성

1. BotFather에서 봇 생성

  1. Telegram에서 @BotFather 검색
  2. /newbot 명령 전송
  3. 봇 이름 입력 (예: MoneyMax Trading Bot)
  4. 봇 username 입력 (예: moneymax_trading_bot)
  5. API 토큰이 발급됩니다 — 복사해두세요
Use this token to access the HTTP API:
7123456789:AAH_xxxxxxxxxxxxxxxxxxxxxxxxxxxx

2. Chat ID 확인

  1. 생성한 봇을 검색하여 /start 전송
  2. 브라우저에서 다음 URL 열기:
https://api.telegram.org/bot<YOUR_TOKEN>/getUpdates
  1. 응답에서 chat.id 값 확인:
json
{
  "result": [{
    "message": {
      "chat": {
        "id": 123456789
      }
    }
  }]
}

3. 환경변수 설정

.env 파일에 추가:

ini
TELEGRAM_BOT_TOKEN=7123456789:AAH_xxxxxxxxxxxxxxxxxxxxxxxxxxxx
TELEGRAM_CHAT_ID=123456789

알림 종류

시작 알림

엔진 시작 시 자동 발송됩니다.

🚀 MoneyMax Auto-Trader Started

Mode: PAPER
Balance: 10,000.00 USDT
Symbols: BTC/USDT, ETH/USDT, SOL/USDT, BNB/USDT
Time: 2025-02-15 14:30 UTC

시그널 알림

매매 시그널 생성 및 주문 실행 시 발송됩니다.

🟢 BUY BTC/USDT

Strategy: crypto_momentum
Confidence: 87%
Price: 97,500.0000
Qty: 0.004380
SL: 94,575.0000
TP: 103,350.0000

• EMA 12 crossed above EMA 26
• ADX 42.5 indicates strong trend
• Price broke 10-bar high

포지션 청산 알림

SL/TP 트리거 또는 수동 청산 시 발송됩니다.

✅ CLOSE BTC/USDT (TAKE_PROFIT)

Entry: 97,500.0000
Exit: 103,350.0000
PnL: +25.60 (+6.00%)
❌ CLOSE ETH/USDT (STOP_LOSS)

Entry: 3,200.0000
Exit: 3,104.0000
PnL: -14.40 (-3.00%)

종료 알림

엔진 종료 시 최종 요약을 발송합니다.

🛑 Auto-Trader Stopped

Final Value: 10,234.50 USDT
Total PnL: +234.50
Return: +2.35%

봇 커맨드

Telegram 봇에 메시지를 보내 현재 상태를 조회할 수 있습니다.

지원 명령어

명령어설명
/status포트폴리오 요약 (총자산, 현금, 수익률, PnL)
/positions오픈 포지션 목록 (진입가, 현재가, PnL, SL/TP)
/signals최근 시그널 이력 (최대 10개)
/help명령어 도움말

/status 응답 예시

📊 Portfolio Status

Total: 10,234.50 USDT
Cash: 8,734.50
Return: +2.35%
Realized PnL: +180.20
Unrealized PnL: +54.30
Open Positions: 2
Trades Today: 3

/positions 응답 예시

📋 Open Positions

🟢 BTC/USDT BUY
  Entry: 97,500.00 → Now: 98,200.00
  Qty: 0.004380  PnL: +3.07 (+0.72%)
  SL: 94,575.00  TP: 103,350.00

🔴 SOL/USDT BUY
  Entry: 185.00 → Now: 183.50
  Qty: 2.700000  PnL: -4.05 (-0.81%)
  SL: 179.45  TP: 196.10

/signals 응답 예시

Recent Signals

+ BTC/USDT BUY @ 97,500.00 (87%) [crypto_momentum] 14:30:00
- ETH/USDT SELL @ 3,200.00 (72%) [crypto_scalp] 14:25:00

봇 폴링

봇은 2초 간격으로 Telegram 서버를 폴링합니다. 시작 시 이전 메시지는 자동으로 스킵됩니다.

정기 포트폴리오 요약

config/trading.yamltelegram_summary_seconds 설정으로 정기적인 포트폴리오 요약을 받을 수 있습니다. 기본값은 3600초(1시간)입니다.

yaml
monitoring:
  telegram_summary_seconds: 3600  # 1시간마다 요약 발송

설정

활성화/비활성화

.envTELEGRAM_BOT_TOKENTELEGRAM_CHAT_ID가 있으면 자동으로 활성화됩니다.

CLI에서 비활성화:

bash
python scripts/auto_trader.py --paper --no-telegram

그룹 채팅에서 사용

  1. 봇을 그룹에 추가
  2. 그룹에서 아무 메시지 전송
  3. getUpdates API에서 그룹의 chat.id 확인 (음수값)
  4. .env에 그룹 chat_id 설정

개인 vs 그룹

개인 Chat ID는 양수, 그룹 Chat ID는 음수입니다. 둘 다 동일하게 작동합니다.

MIT License