A core strength of Gunbot's AutoConfig feature is its ability to dynamically manage strategy parameters for your trading pairs. This is primarily achieved through the overrides object within AutoConfig job definitions, particularly for job types like manageOverrides (to modify existing pairs) and addPairs (to set initial parameters for new pairs). This allows for adaptive and context-aware trading strategies.
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 Purpose of the overrides Objectโ
In Gunbot, each trading pair is assigned a base strategy (e.g., "spotgrid"). This base strategy has default parameter values. However, you can customize the behavior for each specific pair by providing "overrides" โ specific parameter values that take precedence over the base strategy's defaults for that pair only.
The overrides object in an AutoConfig job definition allows you to automate the process of setting or changing these pair-specific overrides.
- For
manageOverridesjob type: If a pair passes the job's filters, the parameters defined in theoverridesobject are applied to that existing pair's configuration inconfig.js. This can modify its current behavior. - For
addPairsjob type: When a new pair is discovered and passes filters, it's added toconfig.jswith the job's specified basestrategy. The parameters in theoverridesobject are then immediately applied as initial custom settings for that new pair.
Configuring the overrides Objectโ
The overrides object is a simple collection of key-value pairs, where each key is the name of a valid Gunbot strategy parameter (case-sensitive, matching those in config.js or strategy definitions) and the value is what you want to set it to.
Example with manageOverrides:
{
"adaptiveRiskManager": {
"enabled": true,
"type": "manageOverrides2",
"schedule": "*/15 * * * *",
"pairs": {
"exchange": "binance",
"include": "USDT-"
},
"filters": {
"highVolatilityDetected": { // Some filter to detect high volatility
"filterType": "minVolatilityPct24h",
"minVolatility": 5.0
}
},
"overrides": { // User setting: Apply these if volatility is high
"STOP_LIMIT": 2, // Example: Set a stop limit
"BUY_ENABLED": false, // Temporarily disable new buys
"SELL_ENABLED": true // Example: Ensure selling is enabled
},
"clearOverrides": false // Optional: if true, would wipe existing overrides first
}
}
In adaptiveRiskManager:
- If a USDT pair on Binance has 24-hour volatility above 5.0%, the parameters
STOP_LIMIT: 2.0,BUY_ENABLED: false, andSELL_ENABLED: truewill be written to that specific pair'soverridesection inconfig.js.
Example with addPairs:
{
"cautiousPairAdder": {
"enabled": true,
"type": "addPairs",
"schedule": "0 0 * * *",
"strategy": "stepgrid", // Base strategy for new pairs
"pairs": { /* ... */ },
"filters": { /* ... */ },
"overrides": { // User setting: Initial overrides for newly added pairs
"STOP_LIMIT": 0.25, // Example: Start with a specific stop limit
"GAIN": 1.0,
"BUY_ENABLED": true // Example: Ensure buying is enabled
}
}
}
In cautiousPairAdder:
- Newly added pairs will get the
stepgridstrategy, and immediately have theirSTOP_LIMITset to 0.25,GAINto 1.0, andBUY_ENABLEDset totrue.
Dynamic Override Values with JavaScriptโ
A powerful feature is that the values within the overrides object can be strings that AutoConfig evaluates as JavaScript expressions at runtime. To trigger this evaluation, the string value must start with a space. This allows access to context variables like this.pair, this.variables, this.tickers, etc.
"overrides": {
"GAIN": " this.variables.globalRiskFactor * 1.5 " // Example: Set GAIN based on a global variable
}
" this.variables.globalRiskFactor * 1.5 ": AdjustsGAINbased on a global variable.
Key Considerationsโ
- Parameter Names: Ensure the keys in your
overridesobject are valid Gunbot strategy parameter names and are cased correctly. clearOverridesOption: InmanageOverridesjobs, theclearOverrides(boolean) parameter determines behavior:false(default): The specified overrides are merged with any existing overrides for the pair. New values overwrite old ones for the same keys.true: All existing overrides for the pair are wiped clean before the new overrides from this job are applied. Use with caution.
- Data Types: Values for overrides should match the expected data type of the strategy parameter (number, boolean, string). If using dynamic JavaScript evaluation, ensure the expression results in the correct type.
- Interaction with Base Strategy: Overrides modify the behavior of the pair's assigned base strategy. They don't replace the strategy itself.
- Debugging: If overrides are not applying as expected, check Gunbot logs for errors. Enable
debug: truein the AutoConfig job to see more detailed filter processing information. Verify parameter names and dynamic script logic carefully.
The overrides object is a cornerstone of AutoConfig's adaptability, allowing you to fine-tune strategy behavior for individual pairs or groups of pairs based on a wide range of conditions, making your Gunbot truly responsive to market dynamics and your evolving trading rules.