Market Data & Web Scraping Beginner

Send Real-Time Algo Trading Buy/Sell Alerts to Telegram in Python

Lightweight Python function using requests to push formatted Markdown buy/sell signal alerts and P&L updates from your trading script to a Telegram chat.

#requests

Problem Statement

When running headless Python scanners or trading bots on a cloud server, you need instant mobile push notifications the moment a Supertrend or EMA crossover fires.

Formula / Core Logic

Sends an HTTP POST payload to https://api.telegram.org/bot/sendMessage with Markdown formatting.

Installation

pip install requests
send-telegram-bot-trading-alerts-python-script.py
import requests

def send_telegram_signal(bot_token, chat_id, symbol, action, price, sl):
    msg = (
        f"*{action} SIGNAL TRIGGERED*\n"
        f"Symbol: `{symbol}`\n"
        f"Entry Price: `{price}`\n"
        f"Stop Loss: `{sl}`"
    )
    url = f'https://api.telegram.org/bot{bot_token}/sendMessage'
    payload = {'chat_id': chat_id, 'text': msg, 'parse_mode': 'Markdown'}
    resp = requests.post(url, json=payload, timeout=10)
    return resp.ok

Get the Complete 100+ Python Quant & Automation Bundle

Instant lifetime access to all production-ready scripts, valuation models, and trading bots ($19).

Buy Full Bundle on Gumroad ($19) →

Frequently Asked Questions

Q: How do I get my Telegram Bot Token and Chat ID?

Message `@BotFather` on Telegram using `/newbot` to get your token, and message `@userinfobot` to retrieve your numeric `chat_id`.