Skip to main content

Hedging for Gunbot Spot Trading

type_autoconfig developer


Example config bundle for hedging with Gunbot. Supports hedging between any two base currencies. This is meant as an working example only. It used Binance as exchange, but you could change that to any preferred exchange.

How does it work?

  • You define a pair as your hedging pair, the example uses USDT-BTC. This pair is ONLY used for hedging, not regular trading.

  • You define a trigger to start hedging, the example monitors Di-/Di+ of the hedging pair on 4h candles

  • When hedging gets triggered, all pairs in the config get evaluated and the following happens:

  • Alts are sold in the most direct way to the currency that is being hedged to. For example if you were trading BTC-ETH and it's time to hedge to USDT, AutoConfig will check if the pair USDT-ETH exists to hedge directly, or if an intermediate step like sell on BTC-ETH > sell USDT-BTC is needed.

  • All balance on the hedging is used to either buy or sell to the currency that is being hedged to.

  • A variable gets set that records which currency was just hedged to. This can be used in other as filter to automatically add pairs that fit the hedging direction.

  • All hedging orders are triggered by overrides forcing pairs to trade in the desired direction, AutoConfig itself does not initiate any trades but leaves it for Gunbot to take care of. The setup consists of two sets with config.js, autoconfig.json and autoconfig-variables.json files, which do the following (summarized):


  • Two jobs that control hedging, one for each direction. They run twice every hour, shortly after the full hour. Twice because there is a slight chance that another job might take precedence, or that the hedging pair did not cycle before the job runs.
  • One job that removes disabled pairs. Alts that have hedged get disabled automatically and are removed by this job.
  • Two optional jobs for automatically adding pairs for the correct base. These are disabled by default and have only one filter set that shows how the direction can be filtered. Set your own filters filters for pair selection when you want to use this. In case the same strategy is used for trading both directions, make sure to set overrides for balance settings in one of these jobs (already set in example).


  • Contains a preset variable for the current direction. Needed to make sure that AutoConfig knows the direction even before it hedged the first time.


  • Contains only one strategy, used for hedging only. This strategy will not trade by itself and is used for monitoring the market conditions of the hedging pair, as well as providing the base balance settings for pairs that are being hedged.
  • Contains only one pair, the hedging pair. This pair MUST be in your config at all times.


Gunbot version Make sure you are on Gunbot 16.7 or higher.


Decide what the current hedging direction is, and use the appropriate set of configs. "Direction" means the base coin that should be accumulated at the start of running this setup.


Make sure you only own balance for the current hedging direction. In the example, either USDT or BTC - not both.


Add your own alt trading pairs and set your own strategy for them. Make sure the MIN_VOLUME_TO_BUY and MIN_VOLUME_TO_SELL values in the hedging strategy are valid for the hedging pair. Make sure to add your exchange keys and gunthy wallet address.


Is fully preconfigured, does not need any manual changes unless you change the hedging pair or want to change the hedging trigger. In case you want to change the hedging pair, make sure to edit these parameters in both hedging jobs: "baseFrom" "baseTo" "hedgePair" "hedgedTo" In case you want to change the trigger that initiates hedging, remove the "adx" filter in both hedging jobs and replace it with filters of your own. When you're ready, copy the file to your gunbot folder and overwrite the existing autoconfig.json file.


Is fully preconfigured. Copy it into your gunbot folder. In case you want to change the hedge pair, make sure to edit this file appropriately.


This setup is meant for educational purposes. Use at your own discretion. Hedging can lead to significant losses when used unwisely, for example when you trigger it too often.


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