An automated Bitcoin trading bot built using the Binance API and Telegram Bot API.
This project demonstrates how algorithmic trading systems can analyze market data, generate trading signals using technical indicators, execute trades automatically, and provide real-time monitoring through Telegram.
β οΈ Educational Purpose OnlyThis project was developed for educational and learning purposes to demonstrate the fundamentals of automated trading systems and algorithmic trading workflows. It is not intended to be used as financial advice or as a production-ready trading solution.
- Automated BTCUSDT trading
- Binance Testnet integration
- Real-time market monitoring
- Telegram bot integration
- Buy and sell signal generation
- Automated order execution
- ATR-based Stop Loss
- ATR-based Take Profit
- Market status reporting
- Account balance monitoring
- Multi-threaded architecture
The bot continuously monitors BTCUSDT market data and evaluates trading opportunities using a combination of traditional technical indicators.
The workflow consists of:
- Fetching market candlestick data from Binance.
- Calculating technical indicators.
- Generating BUY or SELL signals.
- Executing market orders.
- Managing risk using Stop Loss and Take Profit levels.
- Sending updates and alerts through Telegram.
The bot uses a traditional rule-based strategy that combines multiple technical indicators.
- EMA 50
- EMA 200
Used to identify long-term market trends.
Moving Average Convergence Divergence is used to confirm momentum shifts.
Relative Strength Index is used to avoid entering trades during overbought or oversold conditions.
Volume Weighted Average Price helps determine whether the current market price is trading above or below the average traded price.
Average True Range is used to calculate dynamic Stop Loss and Take Profit levels based on market volatility.
A BUY signal is generated when:
- EMA50 > EMA200
- MACD > Signal Line
- RSI is between 30 and 70
- Current Price > VWAP
A SELL signal is generated when:
- EMA50 < EMA200
- MACD < Signal Line
- RSI is between 30 and 70
- Current Price < VWAP
The bot uses ATR-based risk management.
Entry Price - (1.5 Γ ATR)
Entry Price + (2 Γ ATR)
This allows the system to adapt to changing market volatility.
The bot can be monitored through Telegram commands.
Displays the bot startup status and account information.
Displays:
- Current BTC price
- Latest market signal
- Latest candle information
Displays:
- Current position
- Stop Loss
- Take Profit
- Latest trade information
Displays:
- EMA50
- EMA200
- MACD
- Signal Line
- RSI
- VWAP
- ATR
Displays current account balances and profit information.
TradingBot/
β
βββ btc-bot.py
βββ requirements.txt
βββ README.md
β
βββ assets/
β βββ thumbnail.png
β βββ server.png
β βββ telegram1.png
β βββ telegram2.png
β βββ telegram3.png
β
βββ .env
Clone the repository:
git clone https://github.com/yourusername/trading-bot.git
cd trading-botInstall dependencies:
pip install -r requirements.txtThis project uses the Binance Spot Test Network to perform paper trading without risking real funds.
Visit:
https://testnet.binance.vision/
Login using your GitHub account.
After logging in:
-
Navigate to API Management.
-
Click Generate HMAC_SHA256 Key.
-
Copy:
- API Key
- Secret Key
Store these credentials securely.
Create a .env file in the project root:
BINANCE_API_KEY=YOUR_API_KEY
BINANCE_API_SECRET=YOUR_SECRET_KEY
- This project uses Binance Testnet for educational and testing purposes.
- Testnet funds are simulated and have no real monetary value.
- API credentials generated from Testnet cannot be used on the live Binance exchange.
The bot uses Telegram to send trade execution alerts, account information, and market updates.
Open Telegram and search for:
@BotFather
Start a conversation and run:
/newbot
BotFather will ask:
- Bot Name
Example:
BTC Trading Bot
- Bot Username
Must end with:
bot
Example:
btc_trading_bot_2026_bot
After creation, BotFather will provide a Bot Token:
123456789:ABCdefGhIJKlmNoPQRsTUVwxyZ
Save this token securely.
The bot needs your Telegram Chat ID to know where to send notifications.
- Search for your newly created bot.
- Click Start.
- Search Telegram for:
@userinfobot
or
@raw_data_bot
- Click Start.
The bot will reply with your account details:
Id: 987654321
Copy this number.
Update your .env file:
BOT_TOKEN=YOUR_TELEGRAM_BOT_TOKEN
CHAT_ID=YOUR_CHAT_ID
Example:
BINANCE_API_KEY=xxxxxxxx
BINANCE_API_SECRET=xxxxxxxx
BOT_TOKEN=123456789:ABCdefGhIJKlmNoPQRsTUVwxyZ
CHAT_ID=987654321
BINANCE_API_KEY=YOUR_API_KEY
BINANCE_API_SECRET=YOUR_SECRET_KEY
BOT_TOKEN=YOUR_TELEGRAM_BOT_TOKEN
CHAT_ID=YOUR_CHAT_ID
python btc-bot.pyThe application starts:
- Trading Engine Thread
- Telegram Bot Thread
Both services run simultaneously.
Open Telegram bot chat and test:
/start
This project is intended solely for educational and demonstration purposes.
The trading strategy implemented in this project is based on traditional technical analysis indicators such as EMA, MACD, RSI, VWAP, and ATR. While these indicators are commonly used in algorithmic trading systems, they are not guaranteed to produce profitable results.
Financial markets are highly dynamic, noisy, and influenced by countless unpredictable factors. As a result:
- Historical performance does not guarantee future performance.
- Market behavior can change rapidly.
- False signals frequently occur.
- Significant financial losses may occur if the strategy is used without sufficient expertise and risk management.
This implementation should be viewed as a learning tool for understanding automated trading workflows rather than a reliable investment system.
Always perform extensive backtesting, paper trading, and risk assessment before deploying any automated trading strategy in a live environment.
This project demonstrates:
- Binance API Integration
- Telegram Bot Development
- Algorithmic Trading Concepts
- Technical Indicator Calculation
- Risk Management Techniques
- Multi-threaded Python Applications
- Real-time Financial Data Processing
- Backtesting Framework
- Web Dashboard
- Performance Analytics
- Multiple Trading Pairs
- Portfolio Management
- Machine Learning Based Signal Generation
- Advanced Risk Management
- Cloud Deployment



