Automated hedging for bitRage
An example of how to automatically add/remove pairs to bitRage, and hedge automatically from USDT to BTC (or vice versa) when the market direction changes.
This setup requires at least one pair on another exchange, Binance in the example, to calculate pSAR on. Used for this setup:
The delay for this exchange is important, make sure to set this delay a bit higher than how fast your hedging jobs are scheduled.
In my example my hedging jobs run every 5 mins, i want to make sure that binance does not cycle faster than that, why I'll explain below.
The first to jobs collect pSar data, they are only important to save pSar values BEFORE we want to hedge - because this data is used to add pairs for a specific base. without these jobs, no pairs would be added until hedging has started. The only thing that happens here is that the pSar value is checked and saved as variable to be used in other jobs.
The next two jobs are for spotting when it is time to hedge.
Besides checking the pSar value, they also check the previous rounds pSar value if both these pSar values are different, it will set a variable that will initiate hedging.
The job above sets "readyToHedge": "USDT", signaling it is time to hedge to USDT. (a "mirror" job for hedging to BTC also exists)
The next job will initiate the actual hedging:
What it does is check if "readyToHedge": "USDT" exists, and when it does, make the following changes to config.js.
It will set this in your bitrage strategy (as defined in the "brStrat" parameter in this job).
Additionally, it will set the bitrage filters for base, quote and pairs as you define them - so that we can already start trading the new base as soon as such pairs are added (or maybe already are present in config).
While hedging runs, specifically while "BR_PANIC_SELL": is true in config.js - no autoconfig jobs are allowed to run. To use this protection, make sure to define your bitrage strat in each job that should not run during this time, like this:
after hedging completes, Gunbot will restart.
The next job that would run (according to the schedules i set) would make sure to remove EVERY bitrage pair that still has USDT as base. this is optional, but it would clean your config from a fair bit of pairs that should have been panic sold already anyway - doing this will give other pairs more time to cycle.
Besides all that, there are two jobs that just add pairs, in the example only based on volume rankings. depending on which direction pSar signals, these would only add the appropriate pairs.
Additionally, I've set these to also add the bitrage filters for the appropriate base. When you've read carefully, you might ask "didn't we do this during hedging already?" and that's correct.
But this way the filters are also set correctly while your setup still never has hedged.
At last there is a simple job that removes any pair that has no balance above mvts, is not in RT and has no open orders.
USE AT YOUR OWN RISK. THIS CONTENT IS MEANT AS AN EXAMPLE OF HOW TO USE AUTOCONFIG.