Skip to main content

SGA Controller: Complete automation for spotGridAdvanced

type_autoconfig developer

date_of_upload date_of_edit

Changelog

Update v1.19: improve job schedules. Fix several reported issues with pair removal
Update v1.18: fix problem that let the last pair get removed
Update v1.17: add missing reset condition for enabling/disabling CT based on trend
Update v1.16: fix all noCompouding configs, something went wrong generating them in the previous version.
Update v1.15: fix issue that prevented pairs too new to calculate indicators from getting removed.
Update v1.14: add config variants with manually added pairs. Fix bug that caused looping between low and high period candles. Fix bug that caused last pair to get removed. Add config bundles for mex_gunthy
Update v1.13: disable CT if "trend open" is used and 4h chart is still bullish. Add a new setting that controls after how many buy orders the strategy changes to 15m candles: START_PERIOD_CHANGE, configurable in the overrides in the addPairs job (applies to newly added pairs only)
Update v1.12: Add optional BASE_RESERVE_PCT setting for compounding setups, value between 0 and 100. With 0 all base balance gets allocated to trading pairs, with a value of 40 only 60% of your funds may get allocated to trading pairs. Set this in the overrides of the manageOverrides job in autoconfig.json, does not affect pairs that already have a trading limit value set.
Update v1.11: Fix several cases where pairs were left in config while not trading. Add many config bundles with different numbers of pairs.
Update v1.10: Fix binanceus config bundles.
Update v1.09: When using "TREND_OPEN" in the strategy, don't discard active pairs until trend is no longer bullish. Add config bundles for binanceus.
Update v1.08: Add support for new trend options in Gunbot v21.8.1 (you can run older Gunbot versions too). Add config bundles for BUSD pairs on Binance. Add leveraged tokens to pair excludes in Huobi bundles. If you want to change trend options, change it in the overrides in the addpairs job and manageoverrides job (both in autoconfig.json)
Update v1.07: Increase 'mvts' for kraken configs. Fix some pair include filters.
Update v1.06: Fix 'preprocessing' for noCompounding config variants. Make 'minPrice' filter work for all base currencies. Use 5m/15m candles on Kraken (instead of 3m/15m). Increase mvts for BTC pairs to 0.0002 (from 0.0001) to decrease changes of being left with coins that cannot be sold.
Update v1.05: Fix build script for non binance configs. Add config bundles for kraken (untested, not sure if their api rate limits will allow it)
Update v1.04: Add more config bundles for binance, huobi and kucoin. For devs: add a build script to work in readable source and build as valid autoconfig.json
Update v1.03: Fix wrong max number of pairs in USDT bundle.
Update v1.02: Fix several problems handling pairs with very low number of available candles. Start saving current base value history every 4h (current bag value + available base), for possible future usage.
Update v1.01: Small tweaks. Add config bundles without trading limit compounding to use next to other trading pairs, read the additional installation instructions inside their folder.

This config bundle offers completely automated trading with the spotGridAdvanced strategy. You set a few basic strategy settings and the script does the rest. The included strategy settings should easily survive / trade profitably on small to medium ranges. Time will tell about large ranges :)

For advanced users I hope this setup serves as a good template for further optimization. The unminified code is included and the important parts are commented.

Typical trades for this setup

Warnings

  • Because of how trading limit compounding is handled, the setup is difficult to combine with manual trading on the same account
  • Manual trading on the same exchange account and base currency, or manually made config changes can lead to unexpected behavior
  • All pairs for the exchange must be handled by the included AutoConfig jobs
  • READ THE WHOLE INSTRUCTIONS

Includes

  • Ready made config bundles for spot trading on binance, for different base currencies
  • For devs: build script and commented source code. Edit the formatted source and create valid autoconfig files by running 'npm i' (once) and 'npm run build' from the root folder

Features

  • Scans markets for volatile pairs and adds/removes them automatically, trades them with the spotGridAdvanced strategy
  • Supports trading multiple base currencies on the same account, overlap between pairs is prevented automatically
  • Supports the following base currencies: USDT, BUSD, USDC, USD, BTC, ETH, BNB
  • Trades and evaluates the market on both 3m and 15m candles
  • Compounding trading limit
  • Dynamic grid multiplier

Tested on

  • v21.6.2
  • Should stay working in future versions

Notes

  • It is certainly not the holy grail. If you're looking for customization, the addPairs filters are likely what you should start with
  • Don't use all your funds for this. Keeping reserves is always a good idea, you never know what the market will bring in the future
  • Try to keep relatively low numbers of pairs, to ensure frequent processing per pair

Installation instructions

If you use one of the ready made bundles, you can just add your gunthy wallet address and exchange keys. But read on until the end.

If you want more control, follow these installation steps:

  1. Add AutoConfig jobs Use the included autoconfig.json file, or use the importer.
  2. Set exchange Change the exchange in the job to the exchange name you want to use it on. By default it is set to "binance". Make sure to change every single occurence of the exchange name.
  3. Add strategy to config Add the strategy to your config.js file, or use the importer.

Usage instructions

  1. Clean your account! Sell every asset. Leave only base currency that may be used. Make sure to have balances in each base currency you want to use.

(Optional: change settings - important ones explained below)

  1. Enable AutoConfig You will see a few jobs starting to run in the console logs. It takes at least one hour before it adds the first pairs.
  2. One hour later: check if pairs got added and start trading If pairs were added, hit the start trading button. From now on everything is automatic.
  3. Done! The first minutes/hours are a bit chaotic, in terms of the number of settings changes and restarts that go along with it. After all pair slots are actively trading, restarts will happen a lot less frequently. Pairs regularly change from 15m to 3m charts, or vice versa. Unless you refresh the GUI after a period change, you'll still see the "old" period on the chart. This does not affect trading in any way.

Settings options

To control the strategy settings you need to change the relevant overrides in the output of the "addPairs" AutoConfig job. You can do this in the GUI or directly in the autoconfig.json file. It is important to not change pair overrides for running pairs, it can cause unexpected behavior. If you want to change strategy settings, do it in the addPairs job.

The available overrides are shown below, comments are // added after each line. You cannot use these comments in the actual autoconfig.json file. Read "do not change" as: only change if you know exactly what you are doing and you have modified the needed scripts.

"overrides": {
"BUY_METHOD": "spotGridAdvanced", // do not change
"SELL_METHOD": "spotGridAdvanced", // do not change
"$MAX_PAIR_PER_BASE": 4, // Maximum number of same base pairs allowed for active trading
"BUY_ENABLED": false, // do not change
"SELL_ENABLED": true, // do not change
"MIN_VOLUME_TO_SELL": 10, // do not change. See explanation below
"GRID_MULTIPLIER": 1.2, // do not change
"MAX_BUY_COUNT": 10, // maximum number of allowed buy orders per pair
"TRADING_LIMIT": 0.00011, // do not change
"PERIOD": 15, // do not change
"SMAPERIOD": 50, // number of candles used for calculating support / resistance levels, can be changed
"AUTO_GAIN": true, // set true to use the auto gain target, set false to use a fixed percentage target
"GAIN": 0.1, // profit target if auto gain is not used
"TRAILING_MULTIPLIER": 1, // trailing range multiplier
"START_CONT_TRADING": 3, // switch from 3m to 15m chart and allow continuous trading from x 'buy count'
"TL_MULTIPLIER": 1.1, // trading limit multiplier
"CT_TL_MULTIPLIER": 0.8, // ct trading limit multiplier
"STOP_AFTER_SELL": false, // do not change
"NEED_PREPROCESSING": true, // do not change
"NEED_POSTPROCESSING": false, // do not change
"TOTAL_BASE_VALUE": 0, // do not change. combined base value of active pairs for same base
"BAG_SIZE": "none" // do not change. bag value @ break even price
},

MIN_VOLUME_TO_SELL gets automatically set to the following values, following their trading rules (in March 2021):

  • USDT / BUSD / USDC / USD: 10
  • BTC: 0.0001 ETH: 0.005
  • BNB: 0.05
  • other: 0.0001

If your exchange requires different minimums, you need to change these values in the function that sets pairVariables in the addPairs job using a plain text editor.

If you change the maximum number of pairs per base, then make sure to allow for it in the pair filter settings of the addPairs job:

"pairs": {
"exclude": "USDT-BTC,UP,DOWN", // exclude filters. USDT-BTC is excluded to prevent overlap between pairs. UP,DOWN filters out leveraged tokens on binance
"include": "BTC-,USDT-", // apply pair filters on all BTC-xxx and USDT-xxx pairs
"maxPairs": "8", // max number of pairs. make sure to set this to $MAX_PAIR_PER_BASE * the number of allowed base currencies (in this case, 4 * 2)
"noCrossOver": true, // do not change
"exchange": "binance" // the exchange name the job runs on
},

Balance handling

Trading limit is set completely automatically, proportionally to the wallet balance.

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.

The total wallet balance value is calculated at break even price of each bag, this makes the value comparable to how "wallet balance" in futures platforms is used.

Each time a pair is added, or trading gets reenabled after selling a bag a new trading limit value gets set using this logic: available balance for pair = total base value / max number of same base pairs trading limit = initial invest needed to max out available pair balance, considering tl multiplier and max buy count

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

Using the optional BASE_RESERVE_PCT parameter (in the manageOverrides job), you can specify a percentage of the total base balance to keep out from active trades.

Disclaimer

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

Enjoy!

I’d appreciate it if you do not contact me through personal messages about this free config example. Thanks!

Download

sgaController_v1.19.0.zip