Binance Telegram Alerts with Python: Full Setup Guide
Learn how to build real-time Binance Telegram alerts using Python — from API setup to filtering signals and automating your trading notifications.
Learn how to build real-time Binance Telegram alerts using Python — from API setup to filtering signals and automating your trading notifications.
Missing a price move because you weren't watching the screen is one of the most frustrating experiences in crypto trading. The market hit your target at 3 AM, blew through your stop, and you woke up to a loss or a missed entry. Building a Binance Telegram alerts system in Python solves this — your bot watches the market around the clock and pings you the moment something actionable happens. This guide walks through the full setup: connecting to Binance's API, wiring up a Telegram bot, and writing clean filtering logic so your phone doesn't buzz on every 0.1% move.
Python sits at the intersection of readable code and powerful libraries, which makes it the default choice for traders who want to automate without spending weeks learning a language. The python-binance library wraps the entire REST and WebSocket API — you can subscribe to live price streams, order book updates, or kline (candlestick) data in under 20 lines of code. Telegram's Bot API is equally simple: one HTTP POST and a message lands in your chat.
Compared to manual dashboard monitoring across Binance, Bybit, or OKX, a Python script running on a cheap VPS gives you persistent, 24/7 coverage without keeping a browser tab open. It also scales — once the infrastructure is in place, adding a new alert condition is adding a few lines of logic, not rebuilding a workflow from scratch.
Before writing a line of code, you need two things: a Binance API key and a Telegram bot token. On Binance, go to API Management under your profile, create a new key, and enable read-only permissions — you don't need trading permissions just to receive price data, and keeping permissions minimal is basic security hygiene. Store the key and secret in environment variables, never hardcoded in your script.
For Telegram, open a chat with @BotFather, run /newbot, follow the prompts, and copy the token it gives you. Then message your new bot once — any text — so Telegram opens a chat thread. You'll also need your chat ID, which you can get by calling the getUpdates endpoint after sending that first message. With both credentials ready, the actual code comes together quickly.
pip install python-binance requests python-dotenv
import os
from dotenv import load_dotenv
from binance.client import Client
import requests
load_dotenv()
BINANCE_API_KEY = os.getenv("BINANCE_API_KEY")
BINANCE_SECRET = os.getenv("BINANCE_SECRET")
TELEGRAM_TOKEN = os.getenv("TELEGRAM_TOKEN")
TELEGRAM_CHAT_ID = os.getenv("TELEGRAM_CHAT_ID")
client = Client(BINANCE_API_KEY, BINANCE_SECRET)
def send_telegram(message: str):
url = f"https://api.telegram.org/bot{TELEGRAM_TOKEN}/sendMessage"
payload = {"chat_id": TELEGRAM_CHAT_ID, "text": message, "parse_mode": "HTML"}
requests.post(url, json=payload)
Never commit API keys to GitHub. Use a .env file locally and environment variables on your VPS. A leaked Binance key with withdrawal permissions has emptied accounts — read-only is safer for alert bots.
The simplest alert pattern is a threshold check: if the price crosses a level you care about, fire a message. But a naive polling loop that hits the REST API every second will burn through your rate limits fast. The better approach is subscribing to Binance's WebSocket streams, which push data to your script as it happens — no polling, no rate limit headaches, and sub-second latency.
from binance import ThreadedWebsocketManager
ALERT_LEVELS = {
"BTCUSDT": {"above": 70000, "below": 60000},
"ETHUSDT": {"above": 4000, "below": 3200},
}
alerted = set() # prevent duplicate alerts
def handle_message(msg):
if msg.get("e") != "24hrTicker":
return
symbol = msg["s"]
price = float(msg["c"])
levels = ALERT_LEVELS.get(symbol)
if not levels:
return
key_above = f"{symbol}_above"
key_below = f"{symbol}_below"
if price > levels["above"] and key_above not in alerted:
send_telegram(f"🚀 {symbol} crossed ABOVE ${levels['above']:}\nCurrent: ${price:,.2f}")
alerted.add(key_above)
elif price < levels["below"] and key_below not in alerted:
send_telegram(f"⚠️ {symbol} dropped BELOW ${levels['below']:}\nCurrent: ${price:,.2f}")
alerted.add(key_below)
twm = ThreadedWebsocketManager(api_key=BINANCE_API_KEY, api_secret=BINANCE_SECRET)
twm.start()
twm.start_ticker_socket(callback=handle_message, symbol="BTCUSDT")
twm.start_ticker_socket(callback=handle_message, symbol="ETHUSDT")
twm.join()
The alerted set prevents your phone from being spammed every tick once a level is crossed. In production you'd reset this set on a timer or when price moves back through the level — that logic is a few extra lines but critically important for usability. Platforms like Bybit and OKX have similar WebSocket APIs if you want to extend the same pattern to multiple exchanges.
Raw price alerts are just the starting point. Most traders who build alert systems quickly realize that price alone isn't enough — you want context. Is volume spiking? Is this a breakout or a fake-out? Adding a few lightweight filters turns a noise machine into a signal worth acting on.
One effective filter is volume confirmation. If BTCUSDT breaks above $70,000 but 24-hour volume is below its 7-day average, the breakout is suspect. You can pull the 24hr ticker data from Binance's REST API and add a volume check before the alert fires. Another filter is the candle close — waiting for a 15-minute candle to close above the level rather than alerting on a wick reduces false positives significantly.
def get_volume_ratio(symbol: str, interval: str = "1d", lookback: int = 7) -> float:
"""Returns today's volume / average of last N days."""
klines = client.get_klines(symbol=symbol, interval=interval, limit=lookback + 1)
volumes = [float(k[5]) for k in klines]
today_vol = volumes[-1]
avg_vol = sum(volumes[:-1]) / len(volumes[:-1])
return today_vol / avg_vol if avg_vol > 0 else 0
def should_alert(symbol: str, direction: str) -> bool:
ratio = get_volume_ratio(symbol)
if ratio < 0.8: # volume below 80% of average — skip
return False
return True
This is exactly the kind of logic that separates a useful alert system from a noisy one. VoiceOfChain applies similar multi-factor filtering to its real-time trading signals — raw price movement gets cross-referenced against volume, volatility context, and momentum indicators before an alert reaches traders. Combining your own threshold alerts with aggregated signal feeds from platforms like VoiceOfChain gives you both customization and institutional-grade filtering without building everything from scratch.
| Filter Type | What It Checks | Best For |
|---|---|---|
| Price Threshold | Close above/below a fixed level | Key support/resistance levels |
| Volume Ratio | Current volume vs N-day average | Breakout confirmation |
| RSI Condition | RSI overbought (>70) or oversold (<30) | Mean-reversion setups |
| Candle Close | Wait for candle to close before alerting | Reducing wick false positives |
| Percent Change | % move in last X minutes | Momentum/volatility detection |
An alert is only as good as what you do when it fires. Having a pre-defined response for each alert type is the difference between disciplined trading and reactive decision-making. Before you deploy your bot, map out your signal-to-action workflow for each alert condition it monitors.
For example: your bot fires a Telegram alert — ETHUSDT closed above $3,800 on a 4-hour candle with 1.3x average volume. Your workflow: check the broader market context on Binance spot and futures, confirm BTC isn't in a local distribution phase, set a limit entry at $3,780 with a stop at $3,650 and a first target at $4,100. That workflow lives in your head before the alert ever fires, so when your phone buzzes at 2 AM you're executing, not thinking.
VoiceOfChain's signal feed integrates well into this kind of workflow. When their platform detects a momentum shift across on-chain and market data, you get a structured signal with context — not just a price number. Pairing that with your own Python-based threshold alerts on Binance means you're covered from two angles: custom levels you've identified from your own analysis, plus aggregated signals catching moves you might have missed.
Always test your alert bot on Binance Testnet before pointing it at live data. Testnet uses the same API structure but fake funds — it's the safest way to validate your logic without consequences.
A bot running on your laptop stops alerting the moment you close the lid. For continuous operation, you need a VPS — a small cloud server that runs independently. A $5/month instance on any major cloud provider is more than sufficient for a Python alert bot monitoring a handful of symbols. The script uses minimal CPU and RAM.
Once your script is on the server, use systemd or tmux to keep it running. Systemd is cleaner for production — it restarts your bot automatically if it crashes, logs output, and starts on server reboot. Here's a minimal service file:
# /etc/systemd/system/binance-alerts.service
[Unit]
Description=Binance Telegram Alert Bot
After=network.target
[Service]
Type=simple
User=ubuntu
WorkingDirectory=/home/ubuntu/alerts-bot
EnvironmentFile=/home/ubuntu/alerts-bot/.env
ExecStart=/usr/bin/python3 /home/ubuntu/alerts-bot/main.py
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target
sudo systemctl enable binance-alerts
sudo systemctl start binance-alerts
sudo systemctl status binance-alerts # verify it's running
With this setup, your bot survives server reboots, network blips, and Python exceptions — it just restarts and resumes monitoring. If you're also tracking signals from Bitget or Gate.io alongside Binance, each exchange can run as a separate service or as async tasks within the same script.
Building a Binance Telegram alert system in Python is one of the highest-leverage things an active trader can do with a weekend's worth of effort. The core stack — python-binance for data, a simple HTTP call for Telegram delivery, and systemd for persistence — is stable, battle-tested, and cheap to run. The real value isn't the technology; it's the discipline it enforces. When your alerts are precise and your response playbook is defined, market moves stop being stressful surprises and start being pre-planned decision points.
Start simple: one or two symbols, a price threshold, a volume filter. Run it live for a week and see which alerts you actually act on versus which ones you ignore. Tune from there. For traders who want curated signal coverage beyond their own technical levels, VoiceOfChain's real-time signal platform complements this setup well — their aggregated signals catch momentum shifts that pure price alerts miss, and they integrate cleanly into a Telegram-based workflow. Whether you're monitoring BTC on Binance, altcoins on KuCoin, or perpetuals on Bybit, the monitoring infrastructure you build once keeps working for you indefinitely.