An automated Risk Management Monitor Bot for ByBit cryptocurrencies exchange.

Overview

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.

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. It supports TP/SL on Entire Position and TP/SL on Selected Position modes, as well as One-Way Mode. Note that Hedge Mode is only supported on the USDT Perpetuals for now due to ByBit's API limitations, so Hedge Mode is not supported for Inverse Perpetuals and Futures Perpetuals, yet.

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.

Comments
  • Enforce TP / quantity ratio of the position to close.

    Enforce TP / quantity ratio of the position to close.

    Hello Hadi, thank you for the code, the bot is awesome!

    I'm running into the following problem, although it looks like the setup is right, and the info displayed in the terminal is also correct, when I check the exchange the actual ratio for the 1st TP is 100% of the position.

    Am I doing something wrong?

    BTW in my setup I had to replace the line: pybit import HTTP, WebSocket to pybit.usdt_perpetual import HTTP, WebSocket

    Best regards

    Screenshot_21 Screenshot_4 Screenshot_3

    opened by Mantis12 1
  • Auto Take Profit at levels of interest

    Auto Take Profit at levels of interest

    You set the timeframe (eg. 15 min) and it will track the following to take profit at (you can pick any or all levels to TP at):

    • EMAs (add up to 5)
    • MAs (add up to 5)
    • Support/Resistance zones.

    User should have ability to activate/deactivate per position.

    enhancement invalid high-priority 
    opened by hadialaddin 0
  • Manual Lock In Profit button

    Manual Lock In Profit button

    Field to type ratio (%) and Button where once clicked the Bot will place the Stop Loss at that ratio. Eg. if you type 5% it will place the Stop Loss at 5% in profit (almost near breakeven). This is helpful for manually taking profits. The ratio (%) field will allow you to type the value OR next to it will have pre-set ratios (Breakeven, 25%, 50%, 75%, 100%, 200%, 300%)

    enhancement invalid high-priority 
    opened by hadialaddin 0
  • Enforce Take Profits feature

    Enforce Take Profits feature

    Set Profit ratios at which to close partial position size (ratio). Bot should automatically calculate the quantity in real-time based on up-to-date position size, and auto adjust TP size and price levels should position change its size or entry price (so should react to manual take profit or loss).

    Allow Tolerance which is the ratio of how far the level is considered valid to place a TP at (if too close, skip to move to the next level, to avoid repetition if price is volatile).

    enhancement high-priority 
    opened by hadialaddin 0
  • Total Balance Static Stop Loss

    Total Balance Static Stop Loss

    This feature allows you to set a maximum amount (ratio) of your Total Balance you would like to automatically close any position when its Unrealised PnL hits it. This guarantees a position would not loose more than that amount.

    enhancement high-priority 
    opened by hadialaddin 0
  • Static Stop Loss Feature

    Static Stop Loss Feature

    Defining Stop Losses that will be static while the position is at loss. Meaning, if user tries to move it lower or higher, it wouldn't allow that (fixed). But it would allow the move once price is in profit, so you can move it to breakeven or lock in profit.

    enhancement high-priority 
    opened by hadialaddin 0
  • Enforce Lock In Profits Stop Loss feature

    Enforce Lock In Profits Stop Loss feature

    Lock In Profits Stop Loss levels (when price level ratio is hit, position's SL moved to defined price ratio). Note it is a Hard SL meaning you can't loose once you hit those profit levels.

    enhancement high-priority 
    opened by hadialaddin 0
  • Enforce Take Profits feature (Default Hard TP)

    Enforce Take Profits feature (Default Hard TP)

    Hard TP levels (executed as Market Order TP if level reached, and the size ratio is based on remaining in the active position). This is enforced no matter what.

    enhancement high-priority 
    opened by hadialaddin 0
  • Support multiple stop losses total to position size

    Support multiple stop losses total to position size

    Stop Loss should either be:

    • 1 Stop Loss for full position size if no other partial Stop Losses exist (eg. New Position Created with no Stop Loss OR active position cancelled all Stop Losses)
    • 1 additional Stop Loss to complete the remaining of the position size IF partial Stop Losses already exist within the allowed range but don't satisfy the full position size (eg. 1 BTC Active position with only 3 partial Stop Losses: 0.2, 0.55 and 0.1 so a total of 0.85 BTC Stop Losses and remaining 0.15 BTC to complete the total position size)
      • For this case, make sure to first DELETE any partial Stop Losses above the allowed range as we need the total position size to reside within the allowed range
      • Then you add a Stop Loss that has size of remaining to complete the full position size
    enhancement 
    opened by hadialaddin 0
  • TP ladder upon hitting specific price % levels

    TP ladder upon hitting specific price % levels

    Automatically set Take Profit (TP) ladder orders with custom ratios and custom position sizes % to close at each. Eg.

    • TP 25% of open position at 50% price move level
    • TP 25% of open position at 75% price move level
    • TP 40% of open position at 150% price move level
    • .... Etc.

    To fully close a position, just type "100%".

    invalid 
    opened by hadialaddin 0
  • TP1 loop

    TP1 loop

    For some assets (i.e. ADA, RSR - not on BTC), the initial TP point gets in a loop (the order gets canceled and resubmitted over and over again, with the quantity adding up over at Bybit leading to a full 100% of the position on TP1).

    opened by JerryVdV 0
  • Chase order for stop loss (limit + post only) feature

    Chase order for stop loss (limit + post only) feature

    Hello.

    Is it possible to add a chase order ( limit order + post only) for stop loss ? .

    Example : I am in a long trade . Current price : 50,000 Chase Stop loss : 49,995

    If current price goes down to 49,995 the bot execute a "chase stop loss order".

    So the may goes to down 10 point for example , but the bot chase the current price 0.5 point away and when the prices come up 0.5 point it will touch the limit order for the stop loss .

    I think this would be handy , because we all use leverage and a market stop loss with leverage has a great impact in our account . It would be great has that option .

    opened by ingnelson 0
Owner
Hadi Aladdin
Hadi Aladdin
This project is a proof of concept to create a dashboard using Dash to display information about various cryptocurrencies.

This project is a WIP as a way to display useful information about cryptocurrencies. It's currently being actively developed as a proof of concept, and a way to visualize more useful data about various cryptocurrencies.

null 7 Apr 21, 2022
Active github repos of all cryptocurrencies

This repo is to maintain the list of active repositories for all cryptocurrencies that https://codemask.org uses. The active list will be automaticall

CodeMask 5 May 20, 2022
A python tool to track prices of various cryptocurrencies and alert

CryptoPriceTracker This is a tool to track prices of various cryptocurrencies and alert the user once the user defined maximum & minimum target is rea

null 1 Oct 1, 2021
Tracking (of choice) cryptocurrencies' daily prices and moving average.

Crypto-price-moving_average Tracking (of choice) cryptocurrencies' daily prices and moving average. About Alpha Vantage The Alpha Vantage library (htt

Thong Huynh 2 Jan 22, 2022
Two modules that display rates of fiat currencies and cryptocurrencies

currency-rates-polybar Two modules that display rates of fiat currencies and cryptocurrencies Setup Clone the repository somewhere Move (or create sym

Peskov Sergey 2 Apr 3, 2022
DCAStack: an Automated Dollar Cost Averaging Bot for Your Crypto

Welcome to DCA Stack! An Automated Dollar Cost Averaging Bot For Your Crypto Web

null 0 Sep 3, 2022
Fully configurable automated python script to collect most visted pages based on google dork

Ranked pages collector Fully configurable automated python script to collect most visted pages based on google dork Usage This project is still under

Security Analyzer 9 Sep 10, 2022
Microllect - Fully automated btc wallet hack,using advanced protocols

Microllect - Fully automated btc wallet hack,using advanced protocols

Arya kaghazkanani 40 Dec 17, 2022
A Python library to wrap age and minisign to provide key management, encryption/decryption and signing/verification functionality.

A Python library to wrap age and minisign to provide key management, encryption/decryption and signing/verification functionality.

Vinay Sajip 3 Feb 1, 2022
A bot for FaucetCrypto a cryptocurrency faucet. The bot can currently claim PTC ads, main reward and all the shortlinks except exe.io and fc.lc.

A bot for the high paying popular cryptocurrency faucet Faucet Crypto. The bot is built using Python and Selenium, currently it is under active develo

Sourav R S 81 Dec 19, 2022
Freqtrade is a free and open source crypto trading bot written in Python

Freqtrade is a free and open source crypto trading bot written in Python. It is designed to support all major exchanges and be controlled via Telegram. It contains backtesting, plotting and money management tools as well as strategy optimization by machine learning.

null 20.2k Jan 7, 2023
This python module can analyse cryptocurrency news for any number of coins given and return a sentiment. Can be easily integrated with a Trading bot to keep an eye on the news.

Python script that analyses news headline or body sentiment and returns the overall media sentiment of any given coin. It can take multiple coins an

null 185 Dec 22, 2022
This is a fully functioning Binance trading bot that takes into account the news sentiment for the top 100 crypto feeds.

This is a fully functioning Binance trading bot that takes into account the news sentiment for the top 100 crypto feeds.

Andrei 1.5k Jan 4, 2023
Bot to trade crypto trading ranges

crypto-trading-bot Crypto bot with DCA or GRID trading strategy Sends notifictions to telegram chat Crypto bot with webhook feature which can be used

null 3 Jun 18, 2021
A bot that escrows crypto transactions on Reddit

EscrowBot I NEED BCH TESTNET FOR TESTING. Please send me some BCH testnet if you have some: bchtest:qz5eur3prqyvd8u77m6fzf9z6cruz9q7vq4qvgdnuk Depende

Nathan Lim 10 Nov 10, 2022
A bot written in Python to automatically buy tokens on the Binance Smart Chain as soon as liquidity is provided

A bot written in Python to automatically buy tokens on the Binance Smart Chain as soon as liquidity is provided. If you’ve found this bot useful and have profited from it please consider donating any token to my BSC wallet address: 0xE75470B9a7c93038195ca116E342c42F6B3F758b

null 473 Dec 25, 2022
A Trading strategy for the Freqtrade crypto bot.

Important Thing to notice 1) Do not use this strategy on live. It is still undergoing dry-run. 2) The Hyperopt is highly optimized towards "shitcoin"

null 160 Dec 26, 2022
Signarly is a cryptocurrency trading bot.

Signarly is a cryptocurrency trading bot.

Zakaria EL Mesaoudi 5 Oct 6, 2022
A crypto bot that checks the price movement in the markets and creates buy and sell signals

Booter bot Purpose The purpose of this bot is to check the price fluctuations in a given market in binance and create the idealistic signals based on

null 2 Oct 9, 2022