Skip to main content

How to use multiple filter sets (filters, filters2) in AutoConfig?

· 6 min read

Gunbot's AutoConfig feature allows multiple "filter sets" within a single job. A basic job might use just one set of filters (the filters object), but you can define up to ten sets (filters, filters2, ..., filters10). A pair triggers the job's action if it passes any one of these complete filter sets.

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 Logic of Multiple Filter Sets

Each filter set is an independent block of conditions.

  • Within a single filter set (e.g., filters): All rules inside it must be true. This is AND logic.
  • Between multiple filter sets (e.g., filters OR filters2 OR filters3): If a pair satisfies all conditions in any one set, the pair passes the overall evaluation. This is OR logic at the set level.

How to Define Multiple Filter Sets

Add objects named filters2, filters3, and so on, up to filters10, at the same level as the primary filters object. Each object contains its own filter rules.

{
"dynamicPairAdder": {
"enabled": true,
"type": "addPairs",
"schedule": "*/10 * * * *",
"pairs": {
"exchange": "binance",
"include": "USDT-",
"exclude": ""
},
"strategy": "stepgrid",

"filters": { // First set of conditions (e.g., for high volume breakouts)
"volumeCheck": {
"filterType": "minVolume24h",
"minVolume": 2000000
},
"volatilityCheck": {
"filterType": "minVolatilityPct24h",
"minVolatility": 5
}
},

"filters2": { // Second set of conditions (e.g., for steady low-volatility climbers)
"lowSpread": {
"filterType": "maxSpreadPct",
"maxSpread": 0.2
},
"steadySlope": {
"filterType": "minSlopePctInterval",
"minSlope": 0.5,
"lastSnapshots": 24 // Check slope over last 24 snapshots
},
"moderateVolume": {
"filterType": "minVolume24h",
"minVolume": 500000
}
},

"filters3": { // Third set of conditions (e.g., custom logic)
"myCustomRule": {
"filterType": "custom",
"script": " return this.pairName.startsWith('BTC');" // Example: only add BTC pairs
}
}
// Potentially up to filters10
}
}

In the dynamicPairAdder job above:

  • A USDT pair on Binance will be added if it meets:
    • ALL conditions in filters (volume > 2M AND volatility > 5%)
    • OR ALL conditions in filters2 (spread < 0.2% AND slope > 0.5% AND volume > 500k)
    • OR ALL conditions in filters3 (passes the custom script logic).

If a pair satisfies the criteria for filters but not filters2 or filters3, it still passes. If it satisfies filters2 but not filters or filters3, it also passes.

Use Cases and Advantages

  1. Diverse Entry Criteria: Define different market scenarios that warrant adding a pair or applying an override (e.g., bullish conditions, ranging markets, or specific news-driven patterns).
  2. Strategy Specialization: Multiple filter sets can help categorize pairs before applying strategies or overrides. Note: A single addPairs job typically assigns one strategy and one set of overrides to all pairs it adds, regardless of which filter set they passed. To assign different strategies based on conditions, you might need separate addPairs jobs or a workflow using variables (for example, setPairVariable in one job and another job acting on that variable).
  3. Combining Broad and Specific Rules: Use one filter set for broad criteria and another for strict, high-conviction criteria.
  4. Testing Different Filter Combinations: Compare variations without creating separate jobs.
  5. Readability and Organization: Breaking logic into named filter sets can be easier to read than a single, deeply nested filters object.

Important Considerations

  • Order of Evaluation: The order of filters, filters2, etc. does not typically matter because the sets are ORed. A pair is accepted as soon as it passes one full set.
  • Performance: Many filter sets with complex filters can increase processing time for each AutoConfig run. Monitor performance if you use demanding filter types (such as those needing many historical data lookups or custom scripts).
  • Clarity vs. Complexity: Multiple sets can clarify distinct conditions, but too many sets can make logic hard to follow. If conditions diverge sharply, separate AutoConfig jobs may be clearer.
  • Output Actions: For job types like addPairs or manageOverrides, the output action (such as the strategy or overrides) is the same for any pair that passes, regardless of which filter set it passed. If you need different outcomes, use separate jobs or a multi-stage process with variables (for example, one job sets a variable based on filters2, another job acts if that variable is set).

Multiple filter sets add flexibility to AutoConfig. By using AND logic within sets and OR logic between sets, you can design jobs that adapt to different market situations.