Skip to main content

Spot Compounding

tested_in type_autoconfig developer


This script allows you to compound your trading profits on spot exchanges. Nothing more, nothing less.


  • You need Gunbot v24 or higher. Do not try running it on an older version, it will not work
  • Needs to run on all pairs of the same base currency in a single Gunbot instance


  • Compounding trading limit, with an option to keep reserves
  • Reserves can be set per base
  • Can be used with any strategy
  • Can free up funds in case the account runs out of money for further buy orders


  • Preconfigured autoconfig.json files for every supported spot exchange
  • For devs: a build script and commented source code

Balance handling

The setup determines the total available base balance for each traded base, then allocates that between trading pairs. If multiple base currencies are traded, like USDT and BTC, each of these will have it’s own total balance value.

Trading limit gets updated when:

  • when there is no funds to sell: quote balance is worth less than MIN_VOLUME_TO_SELL (so when you start running a pair, or it just completely sold)
  • when trading limit is worth less than MIN_VOLUME_TO_SELL: this is a safety mechanism to correct an unrealistically low value

The total wallet balance value is calculated per base at break even price of each bag + free base currency, this makes the value comparable to how “wallet balance” in futures platforms is used.

Formula for trading limit:


Make sure to allocate enough funds for your number of allowed pairs and settings for TL_RATIO If not enough funds are available for your settings, a fallback trading limit of MIN_VOLUME_TO_SELL * 1.1 is set.

Settings descriptions


Value represents a percentage of base currency to subtract from 'wallet balance' before dividing it between pairs. Setting it to 20 on an USDT pair, means that 20% of the 'wallet balance' is reserved. This value must be set identically on each pair of the same base currency.


Set this to the maximum number of pairs of the same base currency you want to trade. It is no problem to set this higher than your active number of pairs. This value must be set identically on each pair of the same base currency.

"TL_RATIO": 40,

Set this to the max number of buys (assuming each buy is in value of 1x trading limit) to allow for a pair. On grid strategies, this would mirror your setting for MAX_BUY_COUNT. Be aware that this does not directly limit the actual buy count on your strategy, it just divides funds to set the appropriate trading limit. This value can be set individually per pair.

Installation instructions

Use one of the ready made autoconfig.json files (or the job it contains) in the /build folder.

1a. Don't use autoconfig already? Place the selected autoconfig.json file in your gunbot folder, overwriting the existing file.

1b. Already use autoconfig? Copy the job from the selected autoconfig.json file to your existing autoconfig.json file.

  1. Enable AutoConfig You can enable AutoConfig directly in config.js, or using the Gunbot interface. Result in config.js should look like:
"AutoConfig": {
"enabled": true,
  1. Don't start running now! Follow through with the rest of the instructions before doing anything else.

Usage Instructions

  1. Prepare include filters in autoconfig.json This determines which pairs use a compounding trading limit. The job to edit is named like this: "compound_binance". This is best be done directly in the autoconfig.json file, either using the code editor in the Gunbot interface or by using a text editor.

The line to edit looks like this by default:

"include": "-",

To use the compounding script on every pair in your config, there is no need to edit autoconfig.json.

If you want to use compounding on a single base currency, for example USDT, then set the include line like this:

"include": "USDT-",

The - behind the currency is important, because this way it filters out pairs starting with USDT- (and not pairs that might have USDT elsewhere in its pair name)

To use the compounding script on multiple base currencies, for example USDT and BTC, then set the included like this:

"include": "USDT-,BTC-",

Note that there is no blank space between items.

  1. Add required overrides to pairs in config.js This needs to be done directly in the config.js file, either using the code editor in the Gunbot interface or by using a text editor.

There are three overrides that need to be added to each pair running the same base currency:

"TL_RATIO": 40
  1. That's all

It is a good idea to disable trading in your strategy before running the setup for the first time, to verify trading limit gets set correctly.

Expect to see a few overrides appearing, these are used for balance tracking. Do not edit them.

"BAG_SIZE": "none",
"BAG_VALUE": "none",

Build instructions (for devs)

You can find the source code for various functions in the autoconfig.json in the /src folder. The included build script can generate config bundles from that, and takes care of minifying the code.


  • Install Node.js
  • Unpack controller folder. The two variations have their own folders and build script
  • Run: npm install (in the folder where the package.json file is)
  • Edit source code and autoconfig.json template in the /scr/compounding_manual-pairs folder
  • You can add config variations for different exchanges or base currencies in /src/index.js, in the outputVariations array.
  • Run: npm run build
  • Get your configs in the /build folder


It’s not feasible for a free config example to test all possible things that could go wrong. Use with caution!


I’d appreciate it if you do not contact me through personal messages about this free config example. Thanks! Creating and maintaining such setups is a lot of work, it is not reasonable to provide free support on top of that.