Skip to content
Advertisement

How do I receive Tradingview alert Webhooks in Python

I’m trying to have alerts sent via webhook (TradingView’s new feature) to a python program, and use them to make trades with Alpaca.

I tried using ngrok plus this script I found on Github:

https://github.com/Robswc/tradingview-webhooks-bot

After changing the port to 80 (no other port seems to work, I think this is on TradingView’s end) I finally got something to come through:

127.0.0.1 - - [25/Dec/2019 21:26:45] code 400, message Bad request version ('Àx14À')
127.0.0.1 - - [25/Dec/2019 21:26:45] " Ì  ÈÁÄJÂ$/g{$¹¦HºÏE(·úå[:Ü´J÷ D+µ6ÑfYxºûáÙØkc`¸Ø­°ÜAzÜ  À/À0À+À,̨̩ÀÀ   ÀÀ" HTTPStatus.BAD_REQUEST -
127.0.0.1 - - [25/Dec/2019 21:26:51] code 400, message Bad request version ('Àx14À')
127.0.0.1 - - [25/Dec/2019 21:26:51] " Ì  ÈÃE¿¾GЪ6áe>ÃÝnI6MÚ3YÖ·¦7Ñ ïþG{äÉýCVÙA$ºÕ0ÒBô2õ+px¶  À/À0À+À,̨̩ÀÀ   ÀÀ[0m" HTTPStatus.BAD_REQUEST -
127.0.0.1 - - [25/Dec/2019 21:27:47] code 400, message Bad request version ('Àx14À')
4s"H  À/À0À+À,̨̩ÀÀ    ÀÀ" HTTPStatus.BAD_REQUEST -
127.0.0.1 - - [25/Dec/2019 21:27:52] code 400, message Bad HTTP/0.9 request type ('x16x03x01x00Ìx01x00x00Èx03x03x92¯;Hx9cx91ÁD7³x04ʵù¶Ófx9bzúÊä')
127.0.0.1 - - [25/Dec/2019 21:27:52] " Ì  ȯ;HÁD7³Êµù¶ÓfzúÊä Åïn@g" HTTPStatus.BAD_REQUEST -
127.0.0.1 - - [25/Dec/2019 21:27:58] code 400, message Bad request version ('Àx14À')
127.0.0.1 - - [25/Dec/2019 21:27:58] " Ì  ÈèÊh>Rd-«RN?Æ©Àh¯`á-õ¿  űE`²ÈìþWy¼DÅî¿=9ÒüX  À/À0À+À,̨̩ÀÀ ÀÀ" HTTPStatus.BAD_REQUEST -
127.0.0.1 - - [25/Dec/2019 21:28:03] code 400, message Bad request version ('Àx14À')
127.0.0.1 - - [25/Dec/2019 21:28:03] " Ì  ȸêó^é:÷gPç©àóÛq}/p¬<ÉN ö3Ð<½w,øÒpa0&`¬[tý( »ÎV   À/À0À+À,̨̩ÀÀ  ÀÀ" HTTPStatus.BAD_REQUEST -

Anyone have any idea how to get this working? I’m just trying to send some json to the webhook on my local machine, then I can use Alpaca functions to make trades with it. Thanks in advance for any advice you can provide, and please let me know any information that can help further solve this, and I will gladly add it.

Advertisement

Answer

The NGROK url needed /webhook after it. This got me past the 405 error. The other error was caused by running it on port 80 and using http instead of https. I don’t know why this is, but I basically switched it to port 5000 (default port in the Github repo) and added /webhook after the NGROK address and now it’s working as it should.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement