Discord bot that displays live position changes on user's Bybit account and provides real-time price signals depending on chosen strategy.
- Use this guide to create a bot on your Discord account with necessary privileges
- Create
.env
file in root directory with variablesapi_key
,secret_key
anddiscord_bot_token
and corresponding values (found on your Bybit API management page and Discord developer portal) - Install the requirements (
pip install -r requirements.txt
) - Run the main file (
python3 main.py
)
The bot responds to the following commands:
- !active - displays currently open positions on connected Bybit account
- !listen positions - starts watching for real-time changes in USDT perpetual contract positions on Bybit
- !listen signals - starts watching for real-time buy/sell signals for symbols traded via the USDT perpetual contract
- !unlisten positions - stops watching for real-time position changes
- !unlisten signals - stops providing real-time buy/sell signals
- !top winners - displays daily top performing coins
- !top losers - displays daily worst performing coins
- !clear - clears the last 200 messages in Discord channel
After the bot has been started, the live websocket price data from Bybit is filtered and stored in-memory in a pandas dataframe. When it fills up with sufficient data to calculate the RSI values, it will display the coins whose values are above or below certain thresholds. By providing arguments to the Strategy
constructor you can set what timeframes you want the signal calculation to be based upon (interval
- default 5 minutes) and the number of intervals to store in-memory (window
- default 20).
There is currently no way to swap strategies on the fly, and there are so for only two strategies to provide signals - the RSIStrategy
and MACDStrategy
. I have ideas about other strategies, but you are free to help out. I structured the code so it should be simple to get started, and the signals are generated using pandas_ta
library, so it should be relatively simple to implement and most of the code is documented ;)
Yes! By setting the save_to_db
attribute of the PriceHandler
object to True
, the bot will save all incoming price data within each interval to SQLite DB file called DATA.db which will be created in the root directory. Separate tables will be created for each symbol. This allows you to externally analyze incoming price data on the fly.
As a self-thought programmer, I cannot guarantee that the code will work 100%. This is a hobby project. I tried my best, but bugs happen and I'm always learning. Raise an issue in this repository or even better, contribute to the code.