- Notifications
You must be signed in to change notification settings - Fork61
A tradingview webhook trading bot for Binance Exchange.
License
51bitquant/binance-tradingview-webhook-bot
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
A tradingview webhook trading bot for Binance Exchange. you can justsimply set up your own signal alert from tradingview, and the bot willhelp you place order to Binance Spot or Binance Future.
if you want to use algo trader in your strategy, we recommend you to usehowtrader, it implements afew algo trader in tv strategy.
Follow the following step you can create your own Binance tradingviewwebhook bot.
If you don't have a server, you need to buy a server and a domain. Thenresolve your domain to your server ip.
window serverrecommendation:https://www.ucloud.cn/site/active/kuaijie.html?invitation_code=C1x2EA81CD79B8C#dongjing
After setup your own server, you also need to install the nginxsoftware. For window, you can download fromhttps://nginx.org/en/download.html , For MacOs system, you can justtype this command into your terminal:
brew install nginx
Other useful command are:
brew services start nginx
brew services restart nginx
brew services reload nginx
if you don't have the brew installed, just google how to install thehomebrew.
For window server, you just download the nginx software from:https://nginx.org/en/download.html, then unzip and cd to the currentdirectory. Here are the useful command.
start nginx.exe
nginx.exe -s stop
nginx.exe -s quit
nginx.exe -s stop
nginx.exe -s reload (reload)
Then edit the nginx.conf file, and add a server for the Flask Server,then save the nginx.conf
http { server { listen 80; server_name your.domain.com; charset utf-8; location / { proxy_pass http://localhost:8888; } } } # other configurations.After editing the eginx.conf, you need to restart nginx.conf or reloadthe eginx. Finally, run the main.py, like python main.py. You may needto create a python virtual environment.
You may need to register an account fromhttps://www.tradingview.com anddevelop your own strategy and create an alert.
when creating an alert, select the box Webhook Url, and past yourwebhook url like:http://www.your.domain/webhook, for the message body,you can config like this:
{"action": "{{strategy.order.comment}}", "symbol": "ETHUSDT","exchange": "binance_future","price":"{{strategy.order.price}}","close": "{{close}}","passphrase": "your custom password for safety.","strategy_name": "ETHUSDT_15min","some other key": "some other value you need"}In this tradingbot, in order to make the order filled immediately, weuse the market order type. If you trade BTCUSDT, ETHUSDT pairs, theslippage is very small. If you want to use the limit order type, pleasecheckout the code and just change the order type to limit and change theorder's price. Last but not least, you also need to set the commemt atthe your order, like:
strategy.entry('L', strategy.long, comment="long")strategy.entry('S', strategy.short, comment="short")strategy.exit('tp', comment="exit")download the codes and unzip it
create a python interpreter, we recommend using anaconda and create apython 3.9 version interpreter, execute the following command.
create -n mytrader python==3.9
then activate your python interpreter.
conda activate mytrader
cd to your code and install the requirements
pip install -r requirements.txt
the requirements.txt is in the code directories. or you can installthe dependencies one by one:
pip install requests
pip install flask
config your strategy
edit the config.py file, config your apikey, passphrase andstrategies parameters.
run the codes.
if you run on your local computer, you can just run the main.py inpycharm editor(remember to config your project interpreter beforerunning it). or you can execute it in your terminal:
python main.py
if you run on your server, you can use the start.sh script. or inputthe following command in your terminal:
nohup python -u main.py > log.txt 2>&1 &
moreover, if you want to place the order in limit or maker order, justchange place_order function's parameter:
maker order
status,order=binance_future_client.place_order(symbol=symbol,order_side=OrderSide.BUY,order_type=OrderType.MAKER,quantity=Decimal(vol1),price=Decimal(price),client_order_id=order_id )
limit order
status,order=binance_future_client.place_order(symbol=symbol,order_side=OrderSide.BUY,order_type=OrderType.LIMIT,quantity=Decimal(vol1),price=Decimal(price),client_order_id=order_id )
Ok, happy using the Binance Tradingview Webhook bot and have a goodluck.
discord:51bitquant#8078
If you have any question, please feel free to contact me.
About
A tradingview webhook trading bot for Binance Exchange.
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.