Code Monkey home page Code Monkey logo

tradingview-webhook-bot's Introduction

Gnome-YT

This is a tradingview webhook designed to be free & open source. This bot is written using Python & Flask and is designed to run a free heroku server. It will allow you to create custom alerts in tradingview and send them to your own private webhook server that can place trades on your account via the api.

Support can be requested in our Discord:

https://discord.gg/Qb9unmxD6D

Current Exchanges


Help keep this tool free by creating a new account using our referral links below:

Tradingview

Create Bybit Account

Create Binance Futures Account



Video Tutorial:

https://youtu.be/VX68RrMvM5Q



How to Webhook Server on Heroku

1.) Clone Project to Desktop

2.) Create a Heroku Account

Heroku was free, now costs only $7 but is worth it... you are investing you money here and you want to do it right.

3.) Edit config.json to add your own api keys & add a custom key to protect the server.

You need to create new keys on Bybit & give them the correct acess to trade and see token balance

4.) Open a terminal in the cloned directory:

5.) Install Heroku CLI so you can work connect you your webserver.

https://cli-assets.heroku.com/heroku-x64.exe

6.) Submit the following lines into the terminal and press ENTER after each one to procces the code:

git init

heroku login

heroku create --region eu tv-trader-yourservernamehere

git add .

git commit -m "Initial Commit"

git push heroku master

Anytime you need to make a change to the code or the API keys, you can push a new build to Heroku:

git add .

git commit -m "Update"

git push heroku master

How to send alerts from TradingView to your new Webserver

After starting you server, you shoudl see an address that will allow you to access it like below:

https://tv-trader-gnome.herokuapp.com/webhook

You will want to add this when you create a new alert like show below:

image

You will then want to create you syntax based on the format shownb below and place it in the alert msg field

image

Now when your alerts fire off they should go strait to your server and get proccessed on the exchange almost instantly!

TradingView Alerts Format

{
	"key": "678777",
	"exchange": "bybit",
	"symbol": "ETHUSD",
	"type": "Market",
	"side": "Buy",
	"qty": "1",
	"price": "1120",
	"close_position": "False",
	"cancel_orders": "True",
	"order_mode": "Both",
	"take_profit_percent": "1",
	"stop_loss_percent": "0.5"
}

Constant Settings Keys
key unique key that protects your webhook server
exchange bybit, binacne-futures
symbol Exchange Specific ** See Below for more
side Buy or Sell
type Market or Limit
order_mode Both(Stop Loss & Take Profit Orders Used), Profit ( Omly Take Profit Orders), Stop (Only Stop Loss orders)
qty amount of base currency to buy
price ticker in quote currency
close_position True or False
cancel_orders True or False
take_profit_percent any float (0.5)
stop_loss_Percent and float (0.5)

** SYMBOLS

EXCHANGE SYMBOL EXAMPLE
BYBIT INVERSE BTCUSD
BYBIT PERP BTCUSDT
Binance Futures BTC/USDT

tradingview-webhook-bot's People

Contributors

cryptognome avatar kodiii avatar nexusbruno2001 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tradingview-webhook-bot's Issues

Binance Spot

Hi,

Is there any plan to support Binance Spot?

DEX support

Please can anyone add DiFi support for Decentralized Exchange(s)? ๐Ÿ‘
@1inch or @Uniswap etc..
Based on everything happening with CEX users need DEX.

@CryptoGnome :shipit: @kodiii you already have excellent DiFi trading bots + now a Webhook please connect the 2 together!

See 1inch Fusion + Fusion SDK only 18 lines of code.

  • Auto Routing
  • Liquidity Aggregation
  • Zero gas fees
  • Check slippage e.g < -2%
  • Check price impact e.g < -1%
  • Split % Order Amount into e.g 3 chunks to get best price
  • Logging for BUY / SELL = % Profits (PnL) ๐ŸŽ‰

Offering a bounty of ๐Ÿ’ฐ $250 USD ๐Ÿ’ฐ to expedite this feature's completion for everyone's benefit as per:

โ€ข CryptoGnome
โ€ข Paid Bounty
โ€ข Starting to do community bounties paid in crypto, to claim you must submit a working pull request with the fix & DM me in our Discord Here
โ€ข Bounty Award: $10

Error when entering a trade

Hello, i have done everything correctly following your guide, but every time the order is sent to the Exchange, I get these errors:
[2022-07-01 12:26:22,848] ERROR in app: Exception on /webhook [POST]
2022-07-01T12:26:22.848692+00:00 app[web.1]: Traceback (most recent call last):
2022-07-01T12:26:22.848692+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/flask/app.py", line 2077, in wsgi_app
2022-07-01T12:26:22.848693+00:00 app[web.1]: response = self.full_dispatch_request()
2022-07-01T12:26:22.848693+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/flask/app.py", line 1525, in full_dispatch_request
2022-07-01T12:26:22.848694+00:00 app[web.1]: rv = self.handle_user_exception(e)
2022-07-01T12:26:22.848694+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/flask/app.py", line 1523, in full_dispatch_request
2022-07-01T12:26:22.848694+00:00 app[web.1]: rv = self.dispatch_request()
2022-07-01T12:26:22.848694+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/flask/app.py", line 1509, in dispatch_request
2022-07-01T12:26:22.848695+00:00 app[web.1]: return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
2022-07-01T12:26:22.848695+00:00 app[web.1]: File "/app/app.py", line 159, in webhook
2022-07-01T12:26:22.848696+00:00 app[web.1]: bot.run(data)
2022-07-01T12:26:22.848696+00:00 app[web.1]: File "/app/binanceFutures.py", line 182, in run
2022-07-01T12:26:22.848697+00:00 app[web.1]: self.set_risk(data['symbol'], data, stop_loss_price, take_profit_price)
2022-07-01T12:26:22.848697+00:00 app[web.1]: File "/app/binanceFutures.py", line 70, in set_risk
2022-07-01T12:26:22.848697+00:00 app[web.1]: position = exchange.fetch_positions(symbol)
2022-07-01T12:26:22.848697+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/ccxt/binance.py", line 4969, in fetch_positions
2022-07-01T12:26:22.848698+00:00 app[web.1]: return self.fetch_positions_risk(symbols, params)
2022-07-01T12:26:22.848698+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/ccxt/binance.py", line 5010, in fetch_positions_risk
2022-07-01T12:26:22.848698+00:00 app[web.1]: raise ArgumentsRequired(self.id + ' fetchPositionsRisk() requires an array argument for symbols')
2022-07-01T12:26:22.848698+00:00 app[web.1]: ccxt.base.errors.ArgumentsRequired: binance fetchPositionsRisk() requires an array argument for symbols
2022-07-01T12:26:22.849543+00:00 app[web.1]: 10.1.12.232 - - [01/Jul/2022:12:26:22 +0000] "POST /webhook HTTP/1.1" 500 265 "-" "Go-http-client/1.1"

Log error get it work

2023-02-09T00:16:11.296168+00:00 app[web.1]: 10.1.37.53 - - [09/Feb/2023:00:16:11 +0000] "POST /webhook HTTP/1.1" 500 265 "-" "Go-http-client/1.1"
2023-02-09T00:16:16.799124+00:00 app[web.1]: Hook Received!
2023-02-09T00:16:16.799239+00:00 app[web.1]: {'key': '7805189856', 'exchange': 'bybit', 'symbol': 'MATICUSDT', 'type': 'Market', 'side': 'Buy', 'qty': '10', 'price': '1120', 'close_position': 'False', 'cancel_orders': 'False', 'order_mode': 'Both', 'take_profit_percent': '0.5', 'stop_loss_percent': '0.5'}
2023-02-09T00:16:16.799252+00:00 app[web.1]: Cancelling Order
2023-02-09T00:16:17.022367+00:00 app[web.1]: Placing Order
2023-02-09T00:16:17.200716+00:00 app[web.1]: Take Profit Price: 1.3
2023-02-09T00:16:17.200727+00:00 app[web.1]: Stop Loss Price: 1.29
2023-02-09T00:16:17.390823+00:00 app[web.1]: [2023-02-09 00:16:17,390] ERROR in app: Exception on /webhook [POST]
2023-02-09T00:16:17.390824+00:00 app[web.1]: Traceback (most recent call last):
2023-02-09T00:16:17.390825+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.11/site-packages/flask/app.py", line 2525, in wsgi_app
2023-02-09T00:16:17.390825+00:00 app[web.1]: response = self.full_dispatch_request()
2023-02-09T00:16:17.390825+00:00 app[web.1]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-02-09T00:16:17.390826+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.11/site-packages/flask/app.py", line 1822, in full_dispatch_request
2023-02-09T00:16:17.390828+00:00 app[web.1]: rv = self.handle_user_exception(e)
2023-02-09T00:16:17.390828+00:00 app[web.1]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-02-09T00:16:17.390828+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.11/site-packages/flask/app.py", line 1820, in full_dispatch_request
2023-02-09T00:16:17.390828+00:00 app[web.1]: rv = self.dispatch_request()
2023-02-09T00:16:17.390829+00:00 app[web.1]: ^^^^^^^^^^^^^^^^^^^^^^^
2023-02-09T00:16:17.390829+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.11/site-packages/flask/app.py", line 1796, in dispatch_request
2023-02-09T00:16:17.390829+00:00 app[web.1]: return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
2023-02-09T00:16:17.390829+00:00 app[web.1]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-02-09T00:16:17.390829+00:00 app[web.1]: File "/app/app.py", line 112, in webhook
2023-02-09T00:16:17.390830+00:00 app[web.1]: session.place_active_order(symbol=data['symbol'], order_type=data['type'], side=data['side'],
2023-02-09T00:16:17.390830+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.11/site-packages/pybit/init.py", line 497, in place_active_order
2023-02-09T00:16:17.390830+00:00 app[web.1]: return self._submit_request(
2023-02-09T00:16:17.390830+00:00 app[web.1]: ^^^^^^^^^^^^^^^^^^^^^
2023-02-09T00:16:17.390831+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.11/site-packages/pybit/init.py", line 1913, in _submit_request
2023-02-09T00:16:17.390831+00:00 app[web.1]: raise InvalidRequestError(
2023-02-09T00:16:17.390832+00:00 app[web.1]: pybit.exceptions.InvalidRequestError: Position idx not match position mode (ErrCode: 130001) (ErrTime: 00:16:17).
2023-02-09T00:16:17.390841+00:00 app[web.1]: Request โ†’ POST https://api.bybit.com/private/linear/order/create: {'api_key': 'm7f2ex2WfaTB8VQFjr', 'close_on_trigger': False, 'order_type': 'Market', 'price': '1120', 'qty': '10', 'recv_window': 5000, 'reduce_only': False, 'side': 'Buy', 'stop_loss': 1.29, 'symbol': 'MATICUSDT', 'take_profit': 1.3, 'time_in_force': 'GoodTillCancel', 'timestamp': 1675901777200, 'sign': 'e0e13fe95d5a768b78f80162f3ea40c70b3b235ef614233048e0053730525166'}.
2023-02-09T00:16:17.391267+00:00 app[web.1]: 10.1.22.107 - - [09/Feb/2023:00:16:17 +0000] "POST /webhook HTTP/1.1" 500 265 "-" "Go-http-client/1.1"
2023-02-09T00:16:17.395033+00:00 heroku[router]: at=info method=POST path="/webhook" host=tv-trader-hofer.herokuapp.com request_id=f1aedeaa-5b18-4da8-8c96-c42e35a754f7 fwd="52.32.178.7" dyno=web.1 connect=0ms service=593ms status=500 bytes=438 protocol=https
2023-02-09T00:16:22.870180+00:00 app[web.1]: Hook Received!
2023-02-09T00:16:22.870429+00:00 app[web.1]: {'key': '7805189856', 'exchange': 'bybit', 'symbol': 'MATICUSDT', 'type': 'Market', 'side': 'Buy', 'qty': '10', 'price': '1120', 'close_position': 'False', 'cancel_orders': 'False', 'order_mode': 'Both', 'take_profit_percent': '0.5', 'stop_loss_percent': '0.5'}
2023-02-09T00:16:22.870442+00:00 app[web.1]: Cancelling Order
2023-02-09T00:16:23.061776+00:00 app[web.1]: Placing Order
2023-02-09T00:16:23.423932+00:00 heroku[router]: at=info method=POST path="/webhook" host=tv-trader-hofer.herokuapp.com request_id=9b30e9b0-1efe-4c1b-9f7b-f81e42b1e4d8 fwd="52.32.178.7" dyno=web.1 connect=0ms service=553ms status=500 bytes=438 protocol=https
2023-02-09T00:16:23.240116+00:00 app[web.1]: Take Profit Price: 1.3
2023-02-09T00:16:23.240130+00:00 app[web.1]: Stop Loss Price: 1.29
2023-02-09T00:16:23.422349+00:00 app[web.1]: [2023-02-09 00:16:23,421] ERROR in app: Exception on /webhook [POST]
2023-02-09T00:16:23.422350+00:00 app[web.1]: Traceback (most recent call last):
2023-02-09T00:16:23.422351+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.11/site-packages/flask/app.py", line 2525, in wsgi_app
2023-02-09T00:16:23.422351+00:00 app[web.1]: response = self.full_dispatch_request()
2023-02-09T00:16:23.422351+00:00 app[web.1]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-02-09T00:16:23.422372+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.11/site-packages/flask/app.py", line 1822, in full_dispatch_request
2023-02-09T00:16:23.422372+00:00 app[web.1]: rv = self.handle_user_exception(e)
2023-02-09T00:16:23.422372+00:00 app[web.1]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-02-09T00:16:23.422372+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.11/site-packages/flask/app.py", line 1820, in full_dispatch_request
2023-02-09T00:16:23.422373+00:00 app[web.1]: rv = self.dispatch_request()
2023-02-09T00:16:23.422373+00:00 app[web.1]: ^^^^^^^^^^^^^^^^^^^^^^^
2023-02-09T00:16:23.422373+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.11/site-packages/flask/app.py", line 1796, in dispatch_request
2023-02-09T00:16:23.422373+00:00 app[web.1]: return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
2023-02-09T00:16:23.422373+00:00 app[web.1]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-02-09T00:16:23.422374+00:00 app[web.1]: File "/app/app.py", line 112, in webhook
2023-02-09T00:16:23.422374+00:00 app[web.1]: session.place_active_order(symbol=data['symbol'], order_type=data['type'], side=data['side'],
2023-02-09T00:16:23.422374+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.11/site-packages/pybit/init.py", line 497, in place_active_order
2023-02-09T00:16:23.422374+00:00 app[web.1]: return self._submit_request(
2023-02-09T00:16:23.422374+00:00 app[web.1]: ^^^^^^^^^^^^^^^^^^^^^
2023-02-09T00:16:23.422375+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.11/site-packages/pybit/init.py", line 1913, in _submit_request
2023-02-09T00:16:23.422375+00:00 app[web.1]: raise InvalidRequestError(
2023-02-09T00:16:23.422380+00:00 app[web.1]: pybit.exceptions.InvalidRequestError: Position idx not match position mode (ErrCode: 130001) (ErrTime: 00:16:23).
2023-02-09T00:16:23.422385+00:00 app[web.1]: Request โ†’ POST https://api.bybit.com/private/linear/order/create: {'api_key': 'm7f2ex2WfaTB8VQFjr', 'close_on_trigger': False, 'order_type': 'Market', 'price': '1120', 'qty': '10', 'recv_window': 5000, 'reduce_only': False, 'side': 'Buy', 'stop_loss': 1.29, 'symbol': 'MATICUSDT', 'take_profit': 1.3, 'time_in_force': 'GoodTillCancel', 'timestamp': 1675901783240, 'sign': '851db5414e912e4930d86d15c6bb6ce9457e4de37abad23860fcee56320efaee'}.
2023-02-09T00:16:23.422789+00:00 app[web.1]: 10.1.28.206 - - [09/Feb/2023:00:16:23 +0000] "POST /webhook HTTP/1.1" 500 265 "-" "Go-http-client/1.1"

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.