Author: Hadi Aladdin (https://linktr.ee/hadialaddin)

Social Media: @hadialaddin

ByBit Risk Management Monitor Bot

An automated Risk Management Monitor Bot for ByBit cryptocurrencies exchange that forces all open positions to adhere to a specific risk ratio, defined per asset. It supports USDT Perpetual, Inverse Perpetual and Inverse Futures all on Mainnet and Testnet but only for One-Way Mode not Hedge Mode.

Simply, it automatically adds/modifies a Stop Loss for any position created or modified, making sure that the stop loss (after leverage, in case of using Margin) does not exceed a specific limit. For now, it supports TP/SL on Entire Position mode, not TP/SL on Selected Position, and for all pairs.

NOTE: Updating the Leverage won’t automatically update your stop loss for the respective position. You would need to change it upon updating so that it auto adjusts. Use at your own risk.

Demo

Watch this video for a live demo: https://youtu.be/yhkY9F-Py1o

Installation

  • Install the latest version of Python 3: https://www.python.org/downloads/

  • Open the terminal and run the following command to install the required ByBit’s PyBit package:

    • pip install pybit
  • Run the monitor bot using the command:

    • python monitor.py

You can run this Python script as a background process using pm2 to auto reload if it crashes. Install pm2 (https://pm2.keymetrics.io/docs/usage/quick-start/) then:
To start the pm2 monitor process: pm2 start monitor.py --interpreter=python
To stop the pm2 monitor process: pm2 stop monitor

NOTE: In case your server has an older version of Python, you can use “python3” to instead of “python” for all the commands above.

Configuration

Edit the constants defined at the beginning of the monitor.py file to set your ByBit API credentials, as well as specific risk ratios for any specific asset. By default, all assets will have the defined stop_loss_cap_ratio.

Contribute

I will do my best to evolve this project and add more features for Stop Loss and Take Profits to ease implementing trading strategies. If you have any ideas or feature suggestions, please contact me or go to the “Issues” tab above to create ones.

GitHub

View Github