Bybit-Auto-Trading-Bot-Ordes-placed-via-TradingView-Webhook .
After setting up this bot, which is an easy version, you can also get a more advanced version here: ###https://github.com/Mtemi/BybitTelegramBot for free.
You can setup a free version of this bot with the instructions below !!!!
The code provided here may need some development intuition because it may not necessarily work since Bybit keep updating their REST API endpoints and their websockets. Incase of issues installing the code join our discord here: https://discord.gg/XKNBAGtmuB and ask the questions you may have.
Access Bybit Documentation here: https://bybit-exchange.github.io/docs/inverse/#t-introduction
Join our Discord Server https://discord.gg/bwCJTVDbRr for Assistance and Updates
Upgrade with Telegram integration is available as per your requirements.
Python based Bybit.com Trading Bot using TradingView.com alerts via webhooks as a trigger to buy/sell/close/manage positions Importantly make sure you create an account on Bybit as well as TradingView: Have knowledge in preparing a python environment, then normal procedures of running python code applies. A web app of this app is in the making. Where you can set your private and public Bybit keys. The parameters are set from TradingView webhooks. several webhooks can be applied. User is able to set TradingView alerts and decide what will happen when each one fires.
Options available are as follows For opening a trade: Provided are
side - Buy, Sell qty - Which will be the number of contracts - Ideally the user could set a percentage. eg. 10 would mean it would calculate how many contracts 10% of the users balance can get at the current leverage. symbol - BTCUSD, ETHUSD, XRPUSD, EOSUSD Others that can be added/ Some like SL/TS are available: take profit(TP) stop loss(SL) / trailing stop(TS) Before opening a trade it checks to see if the trader is already in a position. If trader is already in a trade of the same direction it will add to the position automatically. If trader is in a trade of the opposite direction it automatically closes that position before opening the new one. For closing a position the bot provides an option to either exit a certain amount of contracts to take partial profits or the close whole position. In terms of giving these commands/variables that decide what action to take,the bot goes into two routes.
Bybit bot is an automated cryptocurrency trading bot that will place orders on Bybit which is not affiliated with TradingView This is a python bot that works with tradingview's webhook alerts! You need a server with a public IP such as 212.49.95.112 which you have to add to TradingView Webhook section. The server ip need to be configured like below: Lines: 43-46 of webhook-bot.py however more requests and responses can be handled here in future. if name == 'main': app.debug = True app.run()
Note: Lines 45 and 46 cannot be active at same time. Line 45 runs local server ip which is then tunneled to Ngrok. Line 46 is important if you have public IP and thus you don’t need Ngrok for tunneling.
Line 46 is commended with # sign so that it’s inactive since line 45 is active for the server to run locally. In my code I have used Ngrok to tunnel my local server ip: 127.0.0.7:80 to a random temporary public address assigned to me by Ngrok. This is the address I placed on TradingView webhook section. This was I was able to make TradingView requests and responses; see lines 21 – 41 of webhook-bot.py file.
On the message section, place a JSON formatted message as below:
{"type": "Market", "side": "Buy", "amount": "10", "symbol": "BTCUSD", "stopLoss": "1", "leverage": "3", "key": "f7dea65b1c167651e830756a94f13d07f0b8c26b6a46f76f2afed966"}
Navigate to config.py file and edit the below configurations
API_KEY = "Enter your api key here"
API_SECRET = "Enter your api secret here"
IS_TEST = False #set to True if you are using testnet
{
"type": "Market",
"side": "Buy",
"amount": "10",
"symbol": "BTCUSD",
"stopLoss": 3,
"leverage": "3",
"trailingStop":"None",
"takeProfit":1,
"key": "f7dea65b1c167651e830756a94f13d07f0b8c26b6a46f76f2afed966"
}
The symbols vary and here is a list extracted form a function: print(list(exchange.markets.keys())) found in line 57 of the project file actions.py. ['.EVOL7D', '.BADAXBT', '.BADAXBT30M', '.BBCHXBT', '.BBCHXBT30M', '.BEOSXBT', '.BEOSXBT30M', '.BXRPXBT', '.BXRPXBT30M', '.BTRXXBT', '.BTRXXBT30M', '.BADAXBT_NEXT', '.BBCHXBT_NEXT', '.BEOSXBT_NEXT', '.BTRXXBT_NEXT', '.BXRPXBT_NEXT', '.BXRP_NEXT', '.BXRP', '.XRPBON', '.XRPBON2H', '.XRPBON8H', '.XRPUSDPI', '.XRPUSDPI2H', '.XRPUSDPI8H', 'XRPH20', 'BCHH20', 'ADAH20', 'EOSH20', 'TRXH20', 'XRP/USD', '.XBT', '.XBT30M', '.XBTBON', '.XBTBON8H', '.XBTUSDPI', '.XBTUSDPI8H', '.XBTBON2H', '.XBTUSDPI2H', '.BXBT', '.BXBT30M', '.BXBT_NEXT', '.BVOL', '.BVOL24H', '.BVOL7D', '.ETHBON', '.ETHBON2H', '.ETHBON8H', '.ETHUSDPI', '.ETHUSDPI2H', '.ETHUSDPI8H', '.BETH', '.BETH30M', '.BETHXBT', '.BETHXBT30M', '.BETH_NEXT', '.BETHXBT_NEXT', '.BLTCXBT', '.BLTCXBT30M', '.BLTCXBT_NEXT', '.USDBON', '.USDBON8H', '.USDBON2H', 'BTC/USD', 'XBTH20', 'XBTM20', 'ETH/USD', 'ETHH20', 'LTCH20'] In our case: we picked the BTC/USD pair. You can pick any other coin pair against usdt. I have commended out the function: print(list(exchange.markets.keys())) found in line 57 of the project file actions.py since I only used it during development to generate markey keys/pais above. We don’t need it now. You will need an Account with Bybiy Platform so that you can generate an API key and secret. You will need to open the actions.py file with any text editor and add your API key and secret codes as in below snip. Lines: 15 – 16. Next you need to familiarize yourself with basic python syntax and how to setup the environment for various Oss: Linux, Windows, macOS. Know a bit of pip command as you may use it a lot in setting up the environment. You also need know a bit of OS commands for both linux, windows. You need some python libraries: Flask, CCXT. Install pipenv and initiate virtual environment: (You need start CMD for Windows as here, is where to run commands); Assume you have pasted the project on this path: C:\Users\ICT\Documents\projects\Bybitpy). ICT is name of my computer. Then on CMD prompt type: CD C:\Users\ICT\Documents\projects\Bybitpy and Bybitpy will be your active directory. Then proceed with below commands.