-
Notifications
You must be signed in to change notification settings - Fork 0
Home
This document contains the content for the project's GitHub Wiki. You can copy each section into a separate page in your GitHub Wiki or keep it as a single reference.
Welcome to the TradingView Webhook Bot Wiki!
This wiki serves as the comprehensive documentation for the TradingView Webhook Bot. Here you will find detailed guides on installation, configuration, usage, and troubleshooting.
- Installation Guide: Step-by-step instructions to get the bot running.
- Configuration: Detailed explanation of all environment variables.
- TradingView Setup: How to configure alerts to trigger the bot.
- User Guide: Telegram commands and bot management.
- Architecture: Technical overview for developers.
- Troubleshooting: Common issues and solutions.
You can run the bot using Docker (recommended) or Python.
- A Virtual Private Server (VPS) with a public IP.
- Docker & Docker Compose installed.
- A Binance Futures account.
-
Clone the Repository
git clone https://github.com/beydah/TradingView-Webhook-Bot.git cd TradingView-Webhook-Bot -
Setup Configuration
cp .env.example .env nano .env
Fill in your API keys and settings (see Configuration).
-
Run the Bot
docker-compose up -d --build
-
Verify Check if the container is running:
docker ps
View logs:
docker logs -f binance-bot
-
Install Python 3.10+
sudo apt update && sudo apt install python3 python3-pip python3-venv -
Create Virtual Environment
python3 -m venv venv source venv/bin/activate -
Install Dependencies
pip install -r requirements.txt
-
Run
python main.py
The bot is configured via the .env file. Do not share this file!
| Variable | Required | Description | Example |
|---|---|---|---|
TELEGRAM_BOT_TOKEN |
✅ | Token from @BotFather | 123456:ABC-DEF... |
TELEGRAM_USER_ID |
✅ | Your Telegram ID from @userinfobot | 123456789 |
BINANCE_API_KEY |
✅ | Binance Futures API Key | vmPUZE... |
BINANCE_SECRET_KEY |
✅ | Binance Futures Secret Key | NhqPt... |
ALERT_KEY |
✅ | Secret password for Webhook validation | SecretPassword123 |
WEBHOOK_IP |
❌ | IP to bind (Default: 0.0.0.0) | 0.0.0.0 |
WEBHOOK_PORT |
❌ | Port to listen on (Default: 80) | 80 |
BINANCE_TESTNET |
❌ | Set 'True' to use Testnet | False |
To automate trades, you need to send Webhooks from TradingView to your bot.
On your TradingView chart, click the Alert icon or press Alt + A.
In the Webhook URL field, enter your server's address:
http://YOUR_VPS_IP/webhook
Tip: If you are using port 80 (default), you don't need to specify it. If you used port 5000, use
http://YOUR_VPS_IP:5000/webhook.
The bot expects a specific JSON format in the Message box.
{
"symbol": "BTCUSDT",
"alert": "long_open",
"price": {{close}},
"key": "SecretPassword123"
}{
"symbol": "BTCUSDT",
"alert": "long_close",
"price": {{close}},
"key": "SecretPassword123"
}{
"symbol": "BTCUSDT",
"alert": "short_open",
"price": {{close}},
"key": "SecretPassword123"
}{
"symbol": "BTCUSDT",
"alert": "short_close",
"price": {{close}},
"key": "SecretPassword123"
}Note: Replace SecretPassword123 with the ALERT_KEY from your .env file.
You can control the bot entirely from Telegram.
-
/start- Wake Up: Starts the bot and shows the menu. -
/help- Help: Lists all available commands. -
/getpos- Positions: Fetches current open positions from Binance. -
/getwallet- Balance: Shows your Futures wallet balance (USDT) and margin usage. -
/getalert- Alerts: Displays the last 20 alerts received from TradingView. -
/getlog- Logs: Generates a text file with the latest bot logs and sends it to you.
The bot will automatically send you messages when:
- An order is opened or closed.
- An error occurs.
- The bot starts or stops.
The project follows a modular architecture using modern Python standards.
app/
├── api/ # FastAPI Webhook Router
├── core/ # Core Infrastructure
│ ├── config.py # Settings Management (Pydantic)
│ ├── database.py # Database Connection (SQLAlchemy)
│ └── logging.py # Logging Configuration
├── models/ # Database Models (Log, Order, Alert)
├── services/ # Business Logic Layers
│ ├── binance_service.py # Binance API Wrapper
│ ├── telegram_service.py # Telegram Bot Logic
│ ├── trade_service.py # Trading Logic & Risk Calculation
│ └── tradingview_service.py # Webhook Queue Manager
└── main.py # Application Entry Point
Technology Stack:
- Language: Python 3.10
- Web Framework: FastAPI + Uvicorn
- Database: SQLite + SQLAlchemy
- Containerization: Docker
- Trading: python-binance
-
Check Logs: Use
/getlogordocker logs binance-bot. - Check Port: Ensure your VPS firewall allows ingress on Port 80.
-
Check Key: Verify
ALERT_KEYin TradingView matches.env.
- Your
BINANCE_API_KEYorBINANCE_SECRET_KEYis incorrect. - IP Restriction on Binance does not include your VPS IP.
- Futures trading is not enabled on your Binance account.
- Check
TELEGRAM_BOT_TOKEN. - Ensure the bot is running (
docker ps). - Send
/startagain.
- Website: beydahsaglam.com
- Email: info.beydahsaglam@gmail.com
- LinkedIn: beydah
- GitHub: beydah