Giter Club home page Giter Club logo

creaoy / tradingview-binance-telegram-bot Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ytrevor81/tradingview-binance-telegram-bot

0.0 0.0 0.0 85 KB

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!

Python 100.00%

tradingview-binance-telegram-bot's Introduction

TradingView-Binance-Telegram-Bot

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

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 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:

Capture

tradingview-binance-telegram-bot's People

Contributors

mysolso avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.