Trailing stop loss and more improvements added to the Binance Volatility Trading bot

It’s been a week since the I shared the Binance Volatility trading bot with you in my recent blog post and I’m excited to share some good news regarding the development of this project.

The trading bot caught the attention of quite a lot of people and we now have an active GitHub developer community, pushing constant updates and improvements to the bot! I would like to thank every who has contributed on GitHub to improving the functionality of this bot. 

Following this boom in developer activity on GitHub, there have been quite a few substantial changes to the code, as well as the way it works. In this article, I will be walking you through the main changes and improvements, as well as how to configure your bot. 

But first a quick description of the bot:

This trading bot will automatically place trades on the Binance exchange by detecting the most volatile coins in a given timeframe.

  • The bot will listen to changes in price across all Coins on Binance paired to USDT
  • We’re excluding Margin (like BTCDOWNUSDT) and Fiat pairs
  • The bot checks if the any coin has gone up by more than 3% in the last minute
  • The bot will buy 100 USDT of the most volatile coins on Binance
  • The bot will sell at 2% profit or 2% stop loss

Main updates to the Binance Volatility Trading Bot

  • Trailing stop loss
  • Better testing environment
  • Easier configuration options
  • Bugfixes and quality of life improvements

These are all easily configurable, and I encourage you to play with these parameters around.

Naturally, you will need a Binance account, so if you don’t have one or would like to use a different account for your bot, use my referral link to get 5% off of your commission fees. Next up is generating an API Key and Secret. You can do that by navigating over to your account > API Management. My previous post includes a step-by-step guide on how to generate API Keys for Binance so follow this link if you need more guidance on how to do it.

I’m first going to cover how to download and run this bot, then we can nerd-out on the configuration options for it.

Running the bot on your machine

The first thing you want to do is download the source code for the Binance Volatility Trading bot from GitHub by clicking on Code and then Download ZIP. Note that you need Python and the pip installer on on your machine in order to run the code and install dependencies.

 

Installing dependencies

Extract the archive and proceed to install the required dependencies from the requirements.txt file

In your cmd/ terminal you have two ways you can go about it:

  • The easy way:
  • The preferred way:

Configuring your bot

Once the dependencies are all out of the way, go ahead and open the creds.example.yml file and paste in your Binance API Key and Secret, and save the file as creds.yml in the same directory. You can open .yml files with any text editor including Notepad.

Now it’s time to configure our Binance Volatility Bot, by giving it some parameters. The bot comes with a predefined trading strategy, but you’re free to modify this as you see fit. In fact I encourage you to do so (in Test mode) so you can see potential profits/losses on different strategies.

So fire up the config.yml and I’ll walk you through the configuration options at your disposal.

Script options

  • TEST_MODE – by default set to True, it will simulate live trades without actually placing trades or using real money. Set this to False (at your own risk) and the bot will use your live account and real funds – so be particularly careful here.
  • LOG_TRADES – by default set to True, it will create a trades.txt file that contains a history of all the trades placed. 
  • LOG_FILE allows you to change the name of the file created by LOG_TRADES

Trading options

  • PAIR_WITH – by default USDT, you may choose to pair with any other fiat or coin
  • QUANTITY – the amount to buy in the Pairing chosen above. Be sure to adjust this if you use a different pairing. 15 USDT is very different from 15 BNB.
  • FIATS – a list of fiats and margin symbols to exclude. If you’ve changed PAIR_WITH, be sure to replace USDT here too.
  • MAX_COINS – the maximum amount of coins that the bot will hold. It won’t buy more until it sells some of what it bought.
  • TIME_DIFFERENCE – the amount of time in MINUTES to check the difference in price against. The minimum is currently 1 minute.
  • RECHECK_INTERVAL – the number of times to check how existing trades are doing during the TIME_DIFFERECE. For example, a RECHECK_INTERVAL of 10 would check the stop loss & Take profit thresholds 10 times in 1 minute.
  • CHANGE_IN_PRICE – the threshold in % that signals a buy
  • STOP_LOSS – the fixed, inital stop loss in %
  • TAKE_PROFIT – the fixied, inital take profit
  • USE_CUSTOM_LIST – by default False, the bot will look at all the coins listed on Binance. Set to True to only look at the top 100.
  • USE_TRAILING_STOP_LOSS – by default True. The bot will increate the stop loss as the price increases, allowing you to ride price increase as long as the increase continues. This should make up for higher gains, so it’s recommended you leave it to True.
  • TRAILING_STOP_LOSS – the % increase that dictates when the stop loss will be moved up.
  • TRAILING_TAKE_PROFIT – the % increate dictating when a new TAKE_PROFIT threshold is updated.

 

  • TRADING_FEE – allows you to adjust this to the current trading fee on your account, in order to provide more accurate profit/loss estimations.
  • SIGNALLING_MODULES – enables the use of custom modules, that can run in parallel to the main script. Read more about signalling modules in my latest blog post on the Binance Volatility Trading bot.

Keeping track of transactions

By default the Binance Volatility Bot will generate and update a text file (trades.txt) that contains all trading activity and the gains/losses of each trade.

coins_bought.json is used by the bot in order to keep track of coins it already bought, and won’t rebuy until sold.

That’s pretty much it, good luck!

Lastly, keep an eye out for further updates and improvements or join our Discord!

Did you enjoy this article? Please consider subscribing to the newsletter for more awesome content.

If you appreciate my content and would like to see more, you can support me by donating here or via the Brave Browser. This is much appreciated as it helps me to keep the content free and open source. Thank you!

18 thoughts on “Trailing stop loss and more improvements added to the Binance Volatility Trading bot

  1. Hi,
    Be awesome send or email or even telegram profit or loses.
    Only this info will be good.

    Just like trade but only The profit info.

    Thanks, Amazing work!

    Ps. About the bot when found The “Change in price”, has and wait The signal? Like wait 1 or 2 SEC for be sure The coin is really up or down.

  2. Hi, I really liked your article thanks for the job!
    I read another article the other day about gold cross and death cross to know when to buy and when to sell.
    Link below:
    https://levelup.gitconnected.com/how-i-tripled-my-return-on-bitcoin-using-mathematics-algorithms-and-python-347edd9b5625

    I was wondering if you could use this with your bot instead of buying or selling with the 2% margin/trailing loss, you use this algorithm that should foresee the market.

    It’s only a suggestion of course.

  3. Hi, would this work on any exchange since we are entering our API keys? I’m specifically interested in using it on Binance U. S. but may want to use it elsewhere. Also with something like this I would need to leave my computer on for it to work, correct? Thanks, G.

    1. It works with Biance us but you have to change the client to client(key, secret, tld=’us’). Won’t work with any other exchanges at the moment.

  4. I love the idea of this. I spent all afternoon trying to figure out python but to no avail. Would anybody have any directions for somebody clueless? i downloaded python and the git but cant seem to figure it out.

  5. I really like the idea. In the past I used heroku for some arbbots.

    This one looks easy to implement. The guide looks good but I didnt install it yet.

    2 remarks; It would be cool to get an daily/weekly update from the trades made actively ported to mail.

    How do you think the bot and the market will respond if many, many users (let’s say millions) will use this bot actively on the market?

  6. Andrei I’m interested in joining the discord! The link above is broken as of now. I’ll look at the code base and see if I can contribute anything from a TA perspective or Web Dev (I’m a full stack developer)

  7. Hey, in the config.yml file you are writing
    # If using 0.75% (using BNB for fees) you must have BNB in your account to cover trading fees.
    I think it should be 0.075%. It was confusing me a bit.

    Best regards
    Andreas

  8. Encountered exception…
    ‘gbk’ codec can’t decode byte 0xae in position 1957: illegal multibyte sequence

    hey,Andreas,why python always error for this everytime i run the bot

  9. Hi Andrei. Awesome work. I am pretty much a trading noob. Once I have made changes to ‘config.yml’, how do I run the bot and how do i stop it? Apologies if you feel this is a suer dumb question.

Leave a Reply

Your email address will not be published. Required fields are marked *