Skip to main content

Write config changes

It can be convenient to programatically change settings in the gunbot config file. After a change to this file, Gunbot picks up the changes automatically.

The following example can be used as a simple way to modify config.js.

// require the node fs module to get access to file system methods
const fs = gb.method.require('fs')

// path of file to modify
const configPath = './config.js'

// prepare config changes, for example place a new override on an existing pair
let configClone = {...gb.data.config}
configClone.pairs.mex_gunthy['USDT-BTC'].override.YOUR_CUSTOM_PARAMETER = 6
const formattedConfig = JSON.stringify(configClone, null, 4)

// write the changes, using a sync method so you can be sure the changes get written right when this line gets executed
fs.writeFileSync(configPath, formattedConfig, 'utf8')