When using Gunbot's AutoConfig addPairs
jobs to dynamically discover and add new trading opportunities, it's often crucial to control the total number of pairs actively trading on an exchange. This helps manage risk, available capital, and system resources. AutoConfig addresses this with the maxPairs
parameter, which sets an upper limit on the number of enabled pairs for a given exchange.
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 maxPairs
Parameter: Controlling Exposureโ
The maxPairs
parameter serves as a ceiling for the number of trading pairs that an AutoConfig addPairs
job will allow to be active simultaneously on a particular exchange. When an addPairs
job identifies new pairs that pass its filters, before adding them to your config.js
, it first checks how many pairs are already enabled for that exchange.
- If the number of currently enabled pairs plus the number of new pairs to be added is less than or equal to
maxPairs
, the new pairs are added. - If adding all new qualifying pairs would exceed
maxPairs
, the job will typically add only enough new pairs to reach themaxPairs
limit. It might prioritize which ones to add based on internal logic or the order they were processed, or it might log that not all potential pairs could be added due to the limit. - If the number of currently enabled pairs is already at or above
maxPairs
, no new pairs will be added by that job run, even if they pass all other filters.
This mechanism is crucial for preventing your bot from accumulating an unmanageable number of active trading positions.
Configuration of maxPairs
โ
The maxPairs
parameter is most commonly configured within the pairs
object of an addPairs
type AutoConfig job.
Example:
{
"smartPairAdder": {
"enabled": true,
"type": "addPairs",
"schedule": "*/30 * * * *", // Runs every 30 minutes
"strategy": "spotgrid",
"pairs": {
"exchange": "kraken",
"include": "-EUR", // Focus on EUR based pairs
"maxPairs": 15 // User setting: Do not exceed 15 enabled pairs on Kraken
},
"filters": {
"minVolumeEUR": {
"filterType": "minVolume24h", // Ensure volume is in quote currency (EUR here)
"minVolume": 20000 // Minimum 20,000 EUR 24h volume
},
"minPriceMovement": {
"filterType": "minVolatilityPct24h",
"minVolatility": 1.0 // At least 1% price movement
}
}
// ... other job settings like 'overrides' ...
}
}
In the smartPairAdder
job:
"exchange": "kraken"
specifies that this job targets the Kraken exchange."maxPairs": 15
sets the limit. This job will not allow more than 15 pairs to be enabled on Kraken as a result of its actions. If there are already 12 enabled pairs on Kraken, and this job finds 5 new EUR pairs that pass filters, it will only add 3 of them to reach the 15-pair limit. If there are already 15 or more enabled pairs, it will add none.
Note on Location: While commonly found under pairs: { ... }
, some older examples or specific Gunbot versions might have interpreted maxPairs
at the top level of the job definition. Always refer to the current Gunbot documentation for the canonical structure. The logic, however, remains the same: it's a per-exchange limit enforced by addPairs
jobs.
How maxPairs
Interacts with Your Setupโ
- Scope:
maxPairs
is typically enforced per exchange. If you haveaddPairs
jobs for multiple exchanges, each can have its ownmaxPairs
limit. - Counting Enabled Pairs: The job counts pairs in your
config.js
for the target exchange that have"enabled": true
. Manually added or disabled pairs are factored into this count. - Pair Removal:
maxPairs
itself does not remove pairs. If you are at yourmaxPairs
limit and want to add new ones, you need a separate mechanism or another AutoConfig job (e.g., typeremovePairs
) to disable or remove underperforming existing pairs to make room. - Multiple
addPairs
Jobs: If you have multipleaddPairs
jobs for the same exchange, they will all respect themaxPairs
limit defined within them. However, they don't coordinate in a sophisticated way beyond checking the current count. The job that runs first and finds qualifying pairs might fill up the slots. Careful scheduling and distinctmaxPairs
values (if desired for different categories of adds) might be needed. - Dynamic
maxPairs
: The value formaxPairs
can also be a string evaluated as JavaScript if it starts with a leading space. This allows for dynamic limits.This example sets"pairs": {
"exchange": "binance",
"maxPairs": " this.variables.conservativeMode ? 5 : 15 ", // Dynamic limit
"include": "USDT-"
}maxPairs
to 5 if a global variableconservativeMode
is true, otherwise to 15.
Benefits of Using maxPairs
โ
- Capital Allocation: Prevents your trading capital from being spread too thinly across an excessive number of pairs, which can diminish returns per trade or hit exchange minimum trade size issues.
- Risk Management: Limits your overall market exposure by capping the number of active positions.
- System Performance: Running strategies on many pairs consumes CPU, memory, and API rate limits.
maxPairs
helps keep these demands manageable. - Focus on Quality: Encourages your filter design to be more selective, as only a limited number of "slots" are available for new pairs.
The maxPairs
parameter is a simple but effective tool for maintaining control over the number of active trading pairs when using AutoConfig's addPairs
functionality. It's a key component in building a sustainable and manageable automated trading system with Gunbot. Regularly review your maxPairs
settings in conjunction with your capital, risk tolerance, and system capacity.