Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A tradingview webhook trading bot for Binance Exchange.

License

NotificationsYou must be signed in to change notification settings

51bitquant/binance-tradingview-webhook-bot

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.

how-to use

Follow the following step you can create your own Binance tradingviewwebhook bot.

1. buy a server、 domain and install the nginx software.

If you don't have a server, you need to buy a server and a domain. Thenresolve your domain to your server ip.

window serverrecommendationhttps://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.

create an alert from tradingview.

You may need to register an account fromhttps://www.tradingview.com anddevelop your own strategy and create an alert.

config your webhook details.

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")

how to run the code

  1. download the codes and unzip it

  2. 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

  3. 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

  4. config your strategy

    edit the config.py file, config your apikey, passphrase andstrategies parameters.

  5. 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.

Contact

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

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp