SystemSelf reportedCryptoPython

TradingView-Binance-Telegram-Bot

An automated trading bot connecting TradingView alerts via webhook to the Binance API, and sending order confirmations or errors to a Telegram user. The user can also send commands to the bot to make new trades, download trade history, cancel open trades, and a variety of other options!

System Structure

Data Used
BinanceOHLCV/호가/체결 데이터
Rules / Strategy

저장소별 전략/실행 조건 확인 필요

Execution

거래소 API 기반 자동 주문 실행

Editor Summary

저장소 설명과 공개 메타데이터 기준으로 Python 기반 구현, 암호화폐 거래 봇, 거래소 API/프레임워크, TradingView 웹훅 성격의 프로젝트로 파악했습니다. 확인 근거는 README, 저장소 설명, GitHub 지표, 파이프라인 필드이며, 주요 데이터는 Binance, OHLCV/호가/체결 데이터입니다. 전략/실행 조건은 저장소별 문서와 코드 확인이 필요하며, 실행 방식은 "거래소 API 기반 자동 주문 실행"라고 보수적으로 기록했습니다. GitHub 지표는 별 151개, 포크 45개입니다.

Repositoryytrevor81/TradingView-Binance-Telegram-Bot
Creatorytrevor81
Stars / Forks★ 151 / 45
Last Updated2025-08-07
Snapshot Date2026-07-08 (README below is a copy from this date)

This is third-party open-source code. QuantField does not guarantee its behavior or safety. Review the code before installing or running it.

README

TradingView-Binance-Telegram-Bot

Flask | Binance API | Telegram API | TradingView Webhook | JSON

(This project was made quite a few years ago and is seriously outdated. This most likely doesn't work out of the box anymore, and I will not make updates. -Trevor 07/08/2025)

An automated trading bot connecting TradingView alerts via webhook to the Binance API, and sending order confirmations or errors to a Telegram user. The user can also send commands to the bot to make new trades, download trade history, cancel open trades, and a variety of other options!

How to run the trading bot

This bot is operated by Flask.

Local Server: After installing the requirements from requirements.txt, open your preferred terminal, navigate into the main directory and type the command "flask run"

Remote Server: After installing Python and the requirements from requirements.txt, configure your server using WSGI. This ensures that your bot is always running. The command "flask run" is not needed for remote servers, unless you want to test the bot in debug mode.

How does the trading bot work?

There are four parts to this trading bot:

  1. Receives TradingView alerts via webhook, at the endpoint "/botwebhook" (found in file app.py)
  2. Send order to Binance API (found in file app.py)
  3. A Telegram messaging bot sends order confirmations from Binance API and error messages to the Telegram bot admin (found in file bot.py)
  4. Send Telegram commands to a Telegram bot connected to the main application.

The user of this trading bot must make a config.py (or a .json file) that holds the desired Binance API keys and the Telegram bot keys. The user must also create a Telegram bot in order to receive notifications from the trading bot.

TradingView Webhook Alert

Set up your TradingView alert to send a JSON message like this:

{ "passphrase": "Your passphrase here", "time": "{{timenow}}", "exchange": "{{exchange}}", "symbol": "{{ticker}}", "quantity": 1.0, "side": "{{strategy.order.action}}", "type": "LIMIT", "timeInForce": "GTC", "currentPrice": {{close}} }

You can change and add any variable you want, as long as it's in JSON format. Any additions, however, must be added to the Binance API call in app.py as well, because the code in app.py will read directly from this alert message.

On TradingView, make sure to include the desired url you would like to send in the 'Webhook URL' input (ex: http://your.server.address/botwebhook)

Telegram Bot

Commands

  1. /start - Saves Chat Id and Username
  2. /help - Receive a notification of all valid commands the bot will process.
  3. /account - Check current account on Binance
  4. /orderhistory {symbol} - Receive a CSV file of all orders made for a specific token (ex. /orderhistory btc)
  5. /openorders {symbol} - Checks all open orders for a specific token (ex. /openorders xrp)
  6. /market {side} {amount} {symbol} - Place a market order on Binance (ex. /market buy 0.01 eth)
  7. /limit {timeInForce} {side} {amount} {symbol} at {price} - Place a limit order on Binance (ex. /limit gtc sell 0.01 eth at 1800)
  8. /stoploss {timeInForce} {side} {amount} {symbol} at {price} stop at {stopLoss} - Place a stoploss limit order on Binance (ex. /stoploss gtc sell 0.1 btc at 55000 stop at 54900)
  9. /ticker {symbol} - Checks the current price of a given token (ex. /ticker btc)
  10. /cancel {symbol} {orderId} - Cancels an open order. It is recommended to call the co