Skip to main content

Control strategy parameters from the GUI

Gunbot provides the option to control specific parameters of a strategy for a particular pair using pair overrides. This allows you to code variables into your strategy, that can be controlled from the browser interface.

To refer to an override value, use the following example:

// Set custom pair overrides in config.js
// These show up in the GUI on the chart overview sidebar
"pairs": {
"binance": {
"USDT-BTC": {
"strategy": "custom",
"enabled": true,
"override": {
"USER_SETTING": true,
"USER_TARGET": "2"
}
}
}
}

// Refer to them like this in your strategy code
const userSetting = gb.data.pairLedger.whatstrat.USER_SETTING
const userTarget = parseFloat(gb.data.pairLedger.whatstrat.USER_TARGET)

whatstrat is a merged object of all Gunbot strategy parameters and pair overrides. Pair overrides take priority over strategy values. Make sure to convert string inputs to numbers using parseFloat() where needed, as the GUI saves them as string values. Additionally, pair overrides can include custom settings that are not known parameters in Gunbot.