Skip to main content

Use AutoConfig to dynamically change global Gunbot settings

ยท 5 min read

Gunbot's AutoConfig feature extends beyond managing trading pairs and their strategies; it can also be used to dynamically alter global bot settings found in the bot section of your config.js file. This is achieved by defining a bot object within an AutoConfig job's action block, allowing for adaptive changes to Gunbot's core behavior based on your specified conditions.

Use the AutoConfig wizard

Nearly every option that follows can be set without editing files by hand.
Click the โ‹ฎ (three-dots) menu โžœ AutoConfig, step through the wizard, and press Save; it will write a correct autoconfig.json for you.

The bot Action Object in AutoConfigโ€‹

When an AutoConfig job successfully passes its filter conditions, it can execute several types of actions. One such action is modifying the global bot settings in your main config.js. This is done by including a bot object in the job definition, at the same level as filters, overrides, or setVariable.

The keys within this bot object should correspond to valid parameter names found within the bot: { ... } section of your config.js (e.g., WATCH_MODE, VERBOSE, BOT_SLEEP_DELAY, TELEGRAM_LEVEL_ALERT, START_PENDING_TIMEOUT_LIMIT). The values you provide will update these settings in config.js.

Configuration Exampleโ€‹

Suppose you want to automatically enable WATCH_MODE and increase the BOT_SLEEP_DELAY if a global AutoConfig variable highRiskMarket is set to true.

{
"riskOffBotAdjuster": {
"enabled": true,
"type": "manageBotSettings", // A conceptual job type; often used with general purpose jobs
// or can be part of jobs like manageOverrides if it makes sense.
// The key is that the 'bot' object is processed.
"schedule": "*/5 * * * *",
"pairs": { /* */ },
"filters": {
"isHighRiskMarket": {
"filterType": "variableExact",
"highRiskMarket": true
}
},
"bot": { // User setting: Global bot settings to change when filters pass
"WATCH_MODE": true
}
}
}

In the riskOffBotAdjuster job:

  • It checks the global variable highRiskMarket.
  • If highRiskMarket is true, the bot action block is processed:
    • WATCH_MODE in your config.js bot section will be set to true.
  • These changes directly modify your config.js file, and Gunbot will typically apply these new settings (some may require a restart to take full effect, though many are live-reloadable).

Job Type Consideration: While you can include the bot object action in various job types (like manageOverrides), if the primary purpose of the job is only to change global bot or exchange settings based on filters (and not process individual pairs for overrides or strategy changes), a more general job type like manageBotSettings (as used conceptually above) or even just a job with filters and the bot/exchange action objects would be appropriate. AutoConfig is flexible; the presence of the bot action object is what matters.

Important Considerationsโ€‹

  • Impact of Changes: Modifying global bot settings can have a significant impact on Gunbot's overall operation. Test these automations thoroughly in a non-critical environment if possible.
  • Setting Names: Ensure the keys in your bot object exactly match the parameter names in the bot section of config.js (case-sensitive).
  • Reloading/Restart: Some global bot settings might require a Gunbot restart to take full effect, while many others are applied dynamically after config.js is reloaded (which AutoConfig triggers upon writing). Refer to Gunbot documentation for specifics on individual parameters.
  • Filter Design: The conditions (filters) that trigger these global changes should be well-thought-out to avoid unintended global behavior modifications.
  • Reverting Changes: Consider having corresponding AutoConfig jobs or logic to revert these global settings when conditions change back. For example, if WATCH_MODE is enabled due to high risk, another job should disable it when the risk subsides.

Using the bot action object in AutoConfig jobs provides a sophisticated way to make your entire Gunbot instance more responsive and adaptive, tuning its core behavior to align with dynamic market conditions or your evolving strategic requirements. This capability truly elevates AutoConfig beyond simple pair management into a comprehensive automation control system.