GitHub – ytrevor81/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

Flask | Binance API | Telegram API | TradingView Webhook | JSON
An automated trade bot connecting TradingView alerts via webhook to the Binance API, and sending order confirmations or errors to a Telegram exploiter. The user can besides send commands to the bot to make newly trades, download barter 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 favored end, voyage 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 constantly running. The command “ flask run ” is not needed for remote control servers, unless you want to test the bot in debug modality .

How does the trading bot work?

There are four parts to this trade bot :

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

The exploiter of this trade bot must make a ( or a .json file ) that holds the craved Binance API keys and the Telegram bot keys. The drug user must besides create a Telegram bot in arrange to receive notifications from the trade bot.

Read more: Forum Policy

TradingView Webhook Alert

Set up your TradingView alert to send a JSON message like this :
{ ” passphrase ” : “ Your passphrase here ”, ” time ” : “ { { timenow } } ”, ” substitute ” : “ { { exchange } } ”, ” symbol ” : “ { { watch } } ”, ” measure ” : 1.0, ” side ” : “ { { strategy.order.action } } ”, ” type ” : “ LIMIT ”, ” timeInForce ” : “ GTC ”, ” currentPrice ” : { { close } } }

You can change and add any variable you want, adenine long as it ‘s in JSON format. Any additions, however, must be added to the Binance API call in vitamin a well, because the code in will read directly from this alert message .
On TradingView, make sure to include the hope url you would like to send in the ‘Webhook URL ‘ remark ( ex-wife : hypertext transfer protocol : //your.server.address/botwebhook )

Telegram Bot


  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 command /openorders first, so that the user can copy and paste the order ID of a trade they would like to cancel. (ex. /cancel btc 6963)
  11. /block – Temporarily blocks automated TradingView orders. This does not block orders made via Telegram command.
  12. /unblock – Unblocks automated TradingView orders.

Order confirmation:


source : https://coinselected
Category : coin 4u

Leave a Reply

Your email address will not be published.