Gunbot's AutoConfig supports on-the-fly decisions based on market data and internal states. When you need external information or custom datasets in filter logic, use acUserData.json. Its contents are available to custom JavaScript filters via the this.userData context variable.
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 acUserData.json File: Your Custom Data Source
The acUserData.json file is the bridge for injecting your own data into AutoConfig.
- Creation: Create the file in the root directory of your Gunbot installation (the same place where
config.jsandautoconfig.jsonreside). - Format: It must be valid JSON. Use any valid JSON constructs: objects, arrays, strings, numbers, booleans.
- Gunbot's Role: When Gunbot starts, or when it detects changes to
acUserData.json(this behavior might vary slightly between versions, but typically it's watched for changes), it reads and parses this file. - Accessibility: The parsed content is available to AutoConfig
customfilter scripts through thethis.userDatacontext object.
Example acUserData.json content:
{
"approvedPairs": ["USDT-BTC", "USDT-ETH", "BTC-ETH"],
"marketSentiment": {
"overall": "neutral",
"btcDominanceFactor": 0.65
},
"customThresholds": {
"minVolumeForTier1": 1000000,
"minVolatilityForAggressive": 3.5
},
"notes": "Data last updated 2023-10-27"
}
Accessing Data with this.userData in Custom Filters
Once acUserData.json is in place and populated, your custom JavaScript filter scripts can reference its content through this.userData.
Consider an AutoConfig job that adds pairs only if they are on an "approved list" maintained in acUserData.json:
{
"whitelistPairAdder": {
"enabled": true,
"type": "addPairs",
"schedule": "0 * * * *", // Hourly
"pairs": {
"exchange": "binance",
"include": "USDT-" // Consider all USDT pairs initially
},
"filters": {
"isOnApprovedList": {
"filterType": "custom",
"script": "/* Using this.userData */ \n const currentPair = this.pairName; \n \n // Check if approvedPairs list exists in userData and currentPair is in it \n if (this.userData && this.userData.approvedPairs && Array.isArray(this.userData.approvedPairs)) { \n if (this.userData.approvedPairs.includes(currentPair)) { \n console.log(currentPair + ' is on the approved list. Filter passes.'); \n return true; \n } else { \n console.log(currentPair + ' is NOT on the approved list.'); \n return false; \n } \n } else { \n console.log('approvedPairs list not found or not an array in acUserData.json.'); \n return false; // Fail safe if data is missing or malformed \n }"
},
"basicVolumeCheck": { // Could be another standard filter
"filterType": "minVolume24h",
"minVolume": 50000
}
},
"strategy": "spotgrid"
}
}
In the isOnApprovedList custom filter:
this.userData && this.userData.approvedPairs && Array.isArray(this.userData.approvedPairs): Checks thatthis.userDataexists, that it has anapprovedPairsproperty, and that property is an array before use. This prevents errors ifacUserData.jsonis missing, empty, or malformed.this.userData.approvedPairs.includes(currentPair): If the checks pass, it uses the standard JavaScriptincludesmethod to see if thecurrentPair(e.g., "USDT-BTC") is present in theapprovedPairsarray loaded fromacUserData.json.
Potential Use Cases for this.userData
- Dynamic Whitelists/Blacklists: Maintain lists of pairs to include or exclude from AutoConfig actions without editing
autoconfig.jsonjobs directly. You can updateacUserData.jsonexternally (e.g., via another script or manually). - External Signal Integration: If you have an external system that generates buy/sell signals or sentiment scores (e.g., from a custom AI model, a paid signal group API you poll, or manual research), you can write these signals into
acUserData.json. Your AutoConfig filters can then read these signals. ExampleacUserData.json:{"signals": {"USDT-BTC": "strong_buy", "USDT-ETH": "neutral"}}Example script:if (this.userData.signals?.[this.pairName] === 'strong_buy') return true; - Tiered Parameters: Define different sets of parameters or thresholds in
acUserData.json(e.g., "tier1_settings", "tier2_settings"). Your filter logic could then apply different conditions based on which tier a pair falls into (perhaps determined by another variable or a characteristic of the pair). - Global Control Flags: Similar to
this.variables, but potentially managed more easily externally. For instance, a global "trading_enabled_for_alts" flag inacUserData.jsoncould be checked by filters. - API Key Storage (Use with Extreme Caution): While technically possible, storing sensitive data like API keys in
acUserData.jsonis generally not recommended due to security implications if the file is not properly secured. Gunbot's mainconfig.jshas better mechanisms for handling encrypted API keys.
Managing acUserData.json
- Valid JSON: Always ensure
acUserData.jsonis valid JSON. Use a JSON validator if you're editing it manually. An invalid JSON file will likely causethis.userDatato be empty or lead to errors. - Updates: Gunbot typically watches
acUserData.jsonfor changes and reloads it. If you update the file while Gunbot is running, the changes should become available to subsequent filter executions. A Gunbot restart also ensures it's loaded. - File Size: While there's no hard limit, extremely large
acUserData.jsonfiles might impact Gunbot's startup time or memory usage during parsing. Keep it reasonably sized and focused on the data your filters actually need. - Backup: Since
acUserData.jsoncontains your custom data, include it in your regular Gunbot configuration backups.
The acUserData.json file and its this.userData object provide a flexible bridge between AutoConfig logic and external data sources or manually curated information. This extends the adaptability and intelligence you can build into automated Gunbot trading strategies.