kopia lustrzana https://github.com/fabston/TradingView-Webhook-Bot
Few minor updates
rodzic
831d960291
commit
246c6807bd
2
LICENSE
2
LICENSE
|
@ -1,6 +1,6 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2020 fabcx
|
||||
Copyright (c) 2020 sixBit
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
57
README.md
57
README.md
|
@ -1,15 +1,47 @@
|
|||
# TradingView Webhook Bot
|
||||
<p align="center"><a href="https://github.com/sixbit/TradingView-Webhook-Bot" target="_blank"><img src="https://i.imgur.com/ubEoI7w.png"></a></p>
|
||||
|
||||
 
|
||||
<p align="center">
|
||||
<a href="https://www.python.org/downloads/release/python-380/"><img src="https://img.shields.io/badge/python-3.8-blue.svg?style=plastic" alt="Python version"></a>
|
||||
<a href="https://github.com/sixBit/TradingView-Webhook-Bot/blob/master/LICENSE"><img src="https://img.shields.io/github/license/sixbit/TradingView-Webhook-Bot?style=plastic" alt="GitHub license"></a>
|
||||
<a href="https://github.com/sixBit/TradingView-Webhook-Bot/issues"><img src="https://img.shields.io/github/issues/sixbit/TradingView-Webhook-Bot?style=plastic" alt="GitHub issues"></a>
|
||||
<a href="https://github.com/sixBit/TradingView-Webhook-Bot/pulls"><img src="https://img.shields.io/github/issues-pr/sixbit/TradingView-Webhook-Bot?style=plastic" alt="GitHub pull requests"></a>
|
||||
<br /><a href="https://github.com/sixBit/TradingView-Webhook-Bot/stargazers"><img src="https://img.shields.io/github/stars/sixbit/TradingView-Webhook-Bot?style=social" alt="GitHub stars"></a>
|
||||
<a href="https://github.com/sixBit/TradingView-Webhook-Bot/network/members"><img src="https://img.shields.io/github/forks/sixbit/TradingView-Webhook-Bot?style=social" alt="GitHub forks"></a>
|
||||
<a href="https://github.com/sixBit/TradingView-Webhook-Bot/watchers"><img src="https://img.shields.io/github/watchers/sixbit/TradingView-Webhook-Bot?style=social" alt="GitHub watchers"></a>
|
||||
<br /><a href="https://sixbit.io/telegram"><img src="https://img.shields.io/badge/Join-Server-00457c.svg?logo=telegram&style=plastic" alt="Join Telegram Server"></a>
|
||||
</p>
|
||||
|
||||
This bot listens to [TradingView](https://tradingview.com) alerts via webhooks and sends them instantly to Telegram, Discord and/or Email.
|
||||
<p align="center">
|
||||
<a href="#about">About</a>
|
||||
•
|
||||
<a href="#features">Features</a>
|
||||
•
|
||||
<a href="#installation">Installation</a>
|
||||
•
|
||||
<a href="#images">Images</a>
|
||||
•
|
||||
<a href="#how-can-i-help">Help</a>
|
||||
</p>
|
||||
|
||||
## Usage
|
||||
1. Clone this repository `git clone https://github.com/fabcx/TradingView-Webhook-Bot.git`
|
||||
## About
|
||||
The **TradingView-Webhook-Bot** ⚙️ listens to [TradingView](https://tradingview.com) alerts via [webhooks](https://www.tradingview.com/support/solutions/43000529348-i-want-to-know-more-about-webhooks/) using [flask](https://flask.palletsprojects.com/en/1.1.x/). All alerts can be instantly sent to Telegram, Discord, Twitter and/or Email.
|
||||
|
||||
## Features
|
||||
- Telegram Support using the [Python Telegram](https://github.com/python-telegram-bot/python-telegram-bot) libary
|
||||
- Discord Support using [webhooks](https://support.discord.com/hc/de/articles/228383668-Webhooks-verwenden)
|
||||
- Twitter Support using [tweepy](https://github.com/tweepy/tweepy) libary
|
||||
- Email Support using [smtplib](https://docs.python.org/3/library/smtplib.html)
|
||||
- Alert channels can be enabled or disabled in [`config.py`](https://github.com/sixBit/TradingView-Webhook-Bot/blob/master/config.py)
|
||||
- Differentiate between Buy and Sell alerts
|
||||
- TradingView `{{close}}`, `{{exchange}}` etc. variables support. Read more [here](https://www.tradingview.com/blog/en/introducing-variables-in-alerts-14880/)
|
||||
|
||||
## Installation
|
||||
> 💡 Best to run the bot on a VPS. I can recommend [vultr](sixbit.io/vultr).
|
||||
1. Clone this repository `git clone https://github.com/sixBit/TradingView-Webhook-Bot.git`
|
||||
2. Create your virtual environment `python3 -m venv TradingView-Webhook-Bot`
|
||||
3. Activate it `source TradingView-Webhook-Bot/bin/activate`
|
||||
3. Activate it `source TradingView-Webhook-Bot/bin/activate && TradingView-Webhook-Bot`
|
||||
4. Install all requirements `pip install -r requirements.txt`
|
||||
5. Edit and update the `config.py` file
|
||||
5. Edit and update [`config.py`](https://github.com/sixBit/TradingView-Webhook-Bot/blob/master/config.py)
|
||||
6. Setup TradingView alerts as shown [here](https://i.imgur.com/71UYTcu.png)
|
||||
- TradingViews variables like `{{close}}`, `{{exchange}}` etc. work as well. More can be found [here](https://www.tradingview.com/blog/en/introducing-variables-in-alerts-14880/)
|
||||
- Your webhook url would be `http://YOUR-IP/webhook`
|
||||
|
@ -18,12 +50,7 @@ This bot listens to [TradingView](https://tradingview.com) alerts via webhooks a
|
|||
*It is recommended to run flask on a different port like 8080. It is then necessary to forward port 80 to 8080.*
|
||||
|
||||
## Images
|
||||

|
||||

|
||||
|
||||
## Donations
|
||||
If you find the bot suitable for your needs, please consider donating whatever amount you like to:
|
||||
|
||||
#### Bitcoin (BTC)
|
||||
```
|
||||
bc1q33xz5sdqqku3629mkeksdglvq3th4l59de8qpz
|
||||
```
|
||||
## How can I help?
|
||||
All kinds of contributions are welcome! The most basic way to show your support is to `⭐️ star` the project, or to raise [issues](https://github.com/sixBit/TradingView-Webhook-Bot/issues/new).
|
|
@ -1,3 +1,9 @@
|
|||
# ----------------------------------------------- #
|
||||
# Plugin Name : TradingView-Webhook-Bot #
|
||||
# Author Name : sixBit #
|
||||
# File Name : config.py #
|
||||
# ----------------------------------------------- #
|
||||
|
||||
# Alert message in TradingView (ex. https://i.imgur.com/RFkuf1d.png)
|
||||
Buy_Alert = 'Buy Alert!'
|
||||
Sell_Alert = 'Sell Alert!'
|
||||
|
|
30
handler.py
30
handler.py
|
@ -1,3 +1,9 @@
|
|||
# ----------------------------------------------- #
|
||||
# Plugin Name : TradingView-Webhook-Bot #
|
||||
# Author Name : sixBit #
|
||||
# File Name : handler.py #
|
||||
# ----------------------------------------------- #
|
||||
|
||||
import config as config
|
||||
from telegram import Bot
|
||||
from discord_webhook import DiscordWebhook
|
||||
|
@ -21,22 +27,19 @@ if twitter:
|
|||
def send_buy_order(data):
|
||||
if telegram:
|
||||
tg_bot.sendMessage(config.channel, data)
|
||||
print('Alert has been sent to Telegram.')
|
||||
else:
|
||||
print('INFO: Telegram alerts are disabled.')
|
||||
pass
|
||||
|
||||
if discord:
|
||||
discord_alert = DiscordWebhook(url=config.discord_webhook, content=data)
|
||||
response = discord_alert.execute()
|
||||
print('Alert has been sent to Discord.')
|
||||
else:
|
||||
print('INFO: Discord alerts are disabled.')
|
||||
pass
|
||||
|
||||
if twitter:
|
||||
tw_api.update_status(status=data)
|
||||
print('Alert has been sent to Twitter.')
|
||||
else:
|
||||
print('INFO: Twitter alerts are disabled.')
|
||||
pass
|
||||
|
||||
if email:
|
||||
email_msg = MIMEText(data)
|
||||
|
@ -48,29 +51,25 @@ def send_buy_order(data):
|
|||
server.login(config.email_user, config.email_password)
|
||||
server.sendmail(config.email_sender, config.email_receivers, email_msg.as_string())
|
||||
server.quit()
|
||||
print('Alert has been sent by email.')
|
||||
else:
|
||||
print('INFO: Email alerts are disabled.')
|
||||
pass
|
||||
|
||||
def send_sell_order(data):
|
||||
if telegram:
|
||||
tg_bot.sendMessage(config.channel, data)
|
||||
print('Alert has been sent to Telegram.')
|
||||
else:
|
||||
print('INFO: Telegram alerts are disabled.')
|
||||
pass
|
||||
|
||||
if discord:
|
||||
discord_alert = DiscordWebhook(url=config.discord_webhook, content=data)
|
||||
response = discord_alert.execute()
|
||||
print('Alert has been sent to Discord.')
|
||||
else:
|
||||
print('INFO: Discord alerts are disabled.')
|
||||
pass
|
||||
|
||||
if twitter:
|
||||
tw_api.update_status(status=data)
|
||||
print('Alert has been sent to Twitter.')
|
||||
else:
|
||||
print('INFO: Twitter alerts are disabled.')
|
||||
pass
|
||||
|
||||
if email:
|
||||
email_msg = MIMEText(data)
|
||||
|
@ -82,6 +81,5 @@ def send_sell_order(data):
|
|||
server.login(config.email_user, config.email_password)
|
||||
server.sendmail(config.email_sender, config.email_receivers, email_msg.as_string())
|
||||
server.quit()
|
||||
print('Alert has been sent by email.')
|
||||
else:
|
||||
print('INFO: Email alerts are disabled.')
|
||||
pass
|
6
main.py
6
main.py
|
@ -1,3 +1,9 @@
|
|||
# ----------------------------------------------- #
|
||||
# Plugin Name : TradingView-Webhook-Bot #
|
||||
# Author Name : sixBit #
|
||||
# File Name : main.py #
|
||||
# ----------------------------------------------- #
|
||||
|
||||
import config as config
|
||||
from flask import Flask, request, abort
|
||||
from handler import send_buy_order, send_sell_order
|
||||
|
|
Ładowanie…
Reference in New Issue