In this article we are going to learn how to create a bot which trades on Bybit using an EMA cross strategy. This bot will also keep you updated of your position on Telegram website. The diagram below explains how the bot works. It goes short when the faster EMA crosses under the slower EMA and goes long when it crosses over.
Create your Telegram bot
Let’s start with Telegram bot. Go to the Telegram website and follow each and every steps of the Bot Father. At the end you will get a chat_id and a token. You will need these two things later.
Create your API keys
Connect to your Bybit account, go to Account & Security then to the API Management section and click on Create New Key. This will give you two keys: an API key and a secret key. Be very careful with these two keys they are confidential, keep them safe.
Clone our Github repository
You will need to clone our Github repository. To do that, go to our Github account. Once you have cloned the repository you will be good to go, just a few more steps to set up and run the bot.
Set up and run the bot
First, set up the working directory in main.py and trading_bot.py. Secondly, set up the Telegram bot by entering your chat_id and token in main.py. And lastly set up the Bybit trading session by entering your API key and secret key in main.py.
To run the script open a terminal and type:
>>>chmod +x path/to/the/directory/main.py >>>nohup path/to/the/directory/main.py &
To stop the script open a terminal and type:
>>>ps -ef >>>kill -9 <pid of the script>
By default the size of your position is set to $1000, to change this edit the size variable in trading_bot.py. Also by default the bot will update you every 15 minutes about your position, you can change this modifying n in bot_update.py.